Attributes in HTML are special words used inside the opening tag of HTML element to control the element's behaviour it's looks and layout. Using attribute we can modify a tag and its contents in different forms. An attribute has value OR property name. Different types of tags/elements may have different types of attributes.
Points to remember for attributes
- HTML attributes are special words which provide additional information about the elements or attributes are the modifier of the HTML element.
- Each element or tag can have attributes, which defines the behaviour of that element.
- Attributes should always be applied with start tag.
- The Attribute should always be applied with its name and value pair.
- The Attributes name and values are case sensitive, and it is recommended by W3C that it should be written in Lowercase only.
- You can add multiple attributes in one HTML element, but need to give space between two attributes.
Some attributes in HTML are common for all tags OR elements these are:
This attribute is used to provide a unique identification for same kind OR different types of elements.While we provide different ids to various elements in that case they can be uniquely accessed.
The title attribute is used to explain an element on hovering the mouse over it. The behavior differs with various elements but generally the value is displayed while loading or hovering mouse pointer over it.
The class attribute is used to associate an element with a style sheet, and specifies the class of element. While we give a space separated value to the class attribute it represents a different class name to that element.
This attribute is used to provide various CSS (Cascading Style Sheets) effects to the HTML elements such as increasing font-size, changing font-family, coloring etc.
<title>Learning HTML attributes</title>
<body> <p id="unique">I am a unique identifier of this tag</p>
"learning HTML attributes"
>I am a title of this element point your mouse here.</
<p class="identifier">I am a unique identifier of this tag by className.</p>
>Hello Myragroup Tutorial.</
I am a unique identifier of this tag
I am a title of this element point your mouse here.
I am a unique identifier of this tag by className.
Hello Myragroup Tutorial.
List of General Attributes
- vspace and more