HTML Tag Attributes
- Attribute adds meta information to a HTML Tag element.
- A HTML can have more than one Attribute.
- Attributes can be optional are mandatory depending on the HTML Tag element.
- Attributes are added to the Start Tag element.
- Attributes have a name and value.
HTML Tag Attribute Example
<a href="http://www.tutorialwalk.com">This is a link</a>
Above given is an example of a HTML Anchor Tag. href is the attribute that adds the url address information to the anchor tag element. href is the attribute name and address is the attribute value.
Let us see one more example using img tag element,
<img src="photo.jpg" width="300" height="150" >
In the above HTML Image Tag element, you can see multiple attributes width, height and src. src is the attribute name and photo.jpg is the address of the file referred. width is the attribute name and 300 is the attribute value in pixels.
You can learn more about the anchor and img tag in their respective chapters.
HTML Tag Attributes General Guidelines
- Though it is not mandatory, use lower case letters for attributes.
- Generally double quotes are used to specify the attribute values. Single quote can also be used. Even without quotes will also work in most of the cases as HTML5 does not mandate the use of quotes.