What are the HTML Attributes?
HTML Attributes define additional properties or characteristics of the element such as height or width of an image. Attributes in HTML are always specified in the opening tag and usually consists of name/value pairs like
name="value". The attribute in HTML values should always be enclosed in quotation marks.
HTML attribute provide additional HTML element details. i.e, HTML links are defined by a tag. The link/hyperlink address is specified in the “href” attribute. Note that attributes in HTML are always enclosed in quotes.
HTML attributes have a few key characteristics:
- HTML attributes provide additional information on HTML elements
- HTML Attributes are always specified in the beginning tag
- Attributes HTML are presented in name/value pairs such as name=value
Also, some attributes are required for certain elements. For instance, an
<img> tag must contain a
In the below example
src inside the
<img> tag is an HTML attribute and image path provided is its value. Similarly
href inside the
<a> tag is an attribute and the link provided is its value, and so on.
General HTML Attributes
There are some HTML attributes, such as
style, etc. that you can use on the majority of HTML elements. The following section describes their usages.
1-The title Attribute
The title HTML attributes is used to provide an element or its content with advisory text. Check out the example below.
2-The id HTML Attribute
3-The class HTML Attribute
Like the Id attribute, elements are also identified with the class attribute. But unlike id, the class attribute doesn’t have to be unique in the document. This means you can apply the same class to multiple elements in a document, as shown in the below example:
4-The style HTML Attributes
The style attribute allows you to specify CSS styling rules such as font,color, border, etc. directly within the element.