09 Jul HTML5 Attributes
HTML5 elements can contain attributes and gets added to an HTML start tag. HTML5 Attributes are used to set properties of a specific element.
If you have an idea about name-value pairs, then it would be easier for you to understand how to work with attributes. Hereās an example,
1 2 3 |
<HTML_tag HTML_Attribute="value">...</tag> |
Here,
- HTML_Tag is the HTML tag i.e. element, for example <img>, <div>, <h1>
- HTML_Attribute is the attribute, which provides value, for example, id, class, href, etc.
Some of the examples are given below,
1 2 3 |
<a href=āhttps://studyopedia.comā>Studyopedia</a> |
As you can see above, href is our attribute for the element a. The href attribute provides the URL.
Another example,
1 2 3 |
<img src="/studyopedia-logo.png" alt="logo" width="50" height="80" /> |
As you can see above, src is our attribute for the element img. The src attribute specifies the URL of the image.
No Comments