1 min to read
Attributes
Attributes give extra info to html elements.
Attributes give extra info to html elements.
- Every element can have attributes
- Attributes gives additional details about an element
- Attributes are written in the start tag always
- Attributes have name-value pairs like name=value
href attribute
Links in html are specified with the <a> element. The link address is defined in the href attribute:
<a href="https://devhoot.ooo" title="DevHoot">This is a link</a>
src attribute
Images in html are specified with the <img> element. The image address is defined in the src attribute:
<img src="smiley.jpg" />
width height attribute
We can specify the width and height of the image with the height & width attributes.
<img src="smiley.jpg" height="200px" width="300px" />
alt attribute
We can also specify text which will be displayed when an image cannot be displayed.
<img src="cry.jpg" alt="cry" />
Comments