HTML Attributes



We have seen a few HTML tags and their usage, like heading tags

,

, paragraph tags

, and other tags. We used them so far in their simplest form, but most of the HTML tags can also have attributes, which are extra bits of information.

What are HTML Attributes?

HTML attributes are special words that provide additional information to an HTML element. Attributes are placed inside the element's opening tag, and they are used to configure or adjust the element's behavior. All attributes are made up of two parts: a name and a value

  • Name: The attribute name is the keyword, also known as the attribute identifier, which defines a specific characteristic for the element in which it is using. For example, the paragraph

    element (in the below-given example) has an attribute "align", which defines the alignment of the paragraph on the page.

  • Value: The attribute value is the data or information that defines the value to be set for that attribute. The value is assigned within the double quotes. For example, "left", "center", or "right" can be assigned to the "align" attribute with the paragraph tag (as shown in the below example).

Below is the syntax of an element HTML having attribute −

...

Rules and Characteristics

The following are the rules and characteristics of HTML attributes; you should follow while using attributes with HTML elements: