Understanding HTML Attributes
HTML attributes provide additional information about HTML elements. They are always specified in the start tag and usually come in name/value pairs like: name="value".
An HTML attribute typically consists of:
<a href="https://www.example.com">Visit Example.com</a>
In this example:
href is the attribute namehttps://www.example.com is the attribute valueSome of the most commonly used HTML attributes include:
href: Specifies the URL of the page the link goes tosrc: Specifies the path to the image to be displayedalt: Specifies an alternate text for an imagestyle: Specifies an inline CSS style for an elementclass: Specifies one or more class names for an elementid: Specifies a unique id for an elementSome attributes are boolean attributes, which means they can have only two values: true or false. The presence of the attribute implies true, while its absence implies false.
<input type="text" disabled>
In this example, disabled is a boolean attribute. Its presence means the input is disabled.
When using HTML attributes, keep these best practices in mind:
role for accessibility).