In previous article we have learn what an HTML is and what are the meaning of the tags used in this language. In this article we will explore the more about “HTML Attributes”.
Attribute of an Element
The elements discussed here can also have its own properties called attributes. An attribute of an element contains extra information regarding it and is not displayed with the actual content. In the above cases you have seen <a> tag with href attribute. These attributes enhance the features of an element.
The attribute of an element can be easily understood by below examples:
Example 1: Image tag consists of an attribute src which specifies the source of the image.
Example 2: We can use attribute to fix height and width of an image too.
Note: Every tag must be closed so that it doesn’t affect other tags. Some tags are empty elements i.e. it doesn’t have separate opening and closing tags, e.g. <Image/> tag, hence it has no content to be shown apart from the image fetched from the source.
From above examples, we can derive that an attribute includes the following:
- A space: A space between the element tag name and an attribute or between two attributes.
- The attribute name: These are predefined for each html tags. These are followed by an equal to sign “=”.
- The attribute value: These are the values assigned to the attribute names. These are wrapped within quotation marks “ ”.