HTML Attributes: Attribute of an Element

by | Jun 8, 2020 | Website Development

Home » Website Development » HTML Attributes: Attribute of an Element


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.


Image tag


Image tag Output

Example 2: We can use attribute to fix height and width of an image too.

Image tag attribute

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.


Image tag attribute Output

HTML Attributes

From above examples, we can derive that an attribute includes the following:

HTML Attributes

  1. A space: A space between the element tag name and an attribute or between two attributes.
  2. The attribute name: These are predefined for each html tags. These are followed by an equal to sign “=”.
  3. The attribute value: These are the values assigned to the attribute names. These are wrapped within quotation marks “ ”.


Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.