Attributes customize the element and specify more information about the element. Write HTML attributes as [name="value"] within the start tag of an HTML element, after the element's name.
What is the difference between the two following elements?
Please click on this button to see the result.
View in Code Editor
In the first line, a heading element (<h3>) is defined without an attribute. But in the second line, the attribute is defined for the heading element. The name of this attribute is align and its value is right. Therefore, the "heading element" is moved to the right.
Attributes can specify the color of the element. Move the element to the right or left. Change the border size of the element. And manipulate other element's attributes.
Set the attributes in the start tag.
First, put the name of the attribute, then the equal sign, and then the value of the attribute. As :
name = "value"
<tag name="value">Element Contents</tag>
Consider the following examples :
|<h3 align="left">First heading</h3>||View in Code Editor|
|<h2 align="right">Second heading</h2>||View in Code Editor|
|<h1 align="center">Third heading</h1>||View in Code Editor|
|<b style="color:blue">This is a bold text</b>||View in Code Editor|