HTML Attributes

HTML attributes are keywords added to starting tag of an HTML element to control the elements behaviour

In the previous section, we learned what HTML elements are and how we structure and use them in our HTML document. HTML Attributes are applied to the opening tag of an HTML element to modify the element behavior or add additional information or just to add a reference.

An attribute generally is applied as key value pairs on the starting tag, take a look below, you will see an an attribute class with a value lead. This is how an attribute with value is applied.

Note than an element can have any number of attributes as required, the attribute names must be separated by atleast a space.

Attribute Classification

HTML Tags are generally classified into two categories:

Tag-Specific Attributes
Those attributes specific to tags for eg. the src attribute is specific to the <img> tag and so on, such attributes are categorized as Tag-Specific which means it will only work with the tags it is intended for.
Global Attributes
These are the common set of attributes that are equally well applicable on almost all tags for eg. id, class, title etc. You can add them to any HTML tag you need and it will work on all of them. A detailed reference with implementation guide is available here HTML Global Attributes Reference
Boolean Attributes

Some content attributes do not require a value, the presence of these attributes in itself represents a "true" value and their absence is same as "false" and this is why they are called Boolean attributes for eg. the required attribute in a <input type="text" required> is a boolean attribute that signifes the input field is required and user must input a value before the form can be submitted.