Each HTML element tells the browser how to display the content it contains. For example, the <hr/> element tells the browser to show a horizontal line. <h1> elements tell the browser to show large heading etc.
Besides the default characteristics of an element, we can add some new characteristics to an element. Adding new characteristics to an element is called an attribute of that element. When the h1 element tells the browser to display a large font heading, you can also specify the color of the heading with the attribute. such as
Go to the online editor, enter the code, and click the "RUN" button to see the yellow title output. Here "style" is an attribute, and "color:yellow;" is the attribute's value. If the attribute is not used, the color of the title will not change. It will default to black. Many such attributes can be added to most tags.
The convention for writing attributes is first the name of the attribute followed by the value within quotation marks ("or '') with an equal sign (=). (all lowercase letters)
There are three types of attribute groups that an element can have. Among these, the core attribute (core attribute) will be seen the most.
id, class, title, and style are core attributes. These attributes will be called global attributes in the following tutorials. Several new attributes have come in HTML 5, such as contenteditable, contextmenu, draggable, dropzone, etc., which will be discussed in detail later. Note that global attributes are used on all elements except a few HTML elements.
The internationalization attributes are dir, lang.
And there are UI event attributes like onclick, ondblclick, onmouseout, onkeypress, etc. These will be called event attributes in all tutorials from now on. But remember that event attributes are only used for JavaScript functions.
The element can be named with id, and class, then CSS styling is done using that name.
Suppose the title attribute is given to an element. In that case, you can use it to display information as a tooltip.
I have shown the style attribute in the first example. Here I have only changed the color. If you want, you can use many more CSS properties.
I didn't discuss other attributes, but when I use them in a tutorial, I will.