HTML Attributes - Javatpoint
HTML Attributes - Javatpoint
ADVERTISEMENT
HTML Attribute
ADVERTISEMENT ADVERTISEMENT
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.
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.
Syntax
<element attribute_name="value">content</element>
https://www.javatpoint.com/html-attributes 2/12
5/2/24, 4:18 PM HTML Attributes - javatpoint
Example
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1> This is Style attribute</h1>
<p style="height: 50px; color: blue">It will add style property in element</p>
<p style="color: red">It will change the color of content</p>
</body>
</html>
Test it Now
Output:
<p style="height: 50px; color: blue">It will add style property in element</p>
Test it Now
https://www.javatpoint.com/html-attributes 3/12
5/2/24, 4:18 PM HTML Attributes - javatpoint
In the above statement, we have used paragraph tags in which we have applied style attribute. This
attribute is used for applying CSS property on any HTML element. It provides height to paragraph
element of 50px and turns it colour to blue.
In the above statement we have again used style attribute in paragraph tag, which turns its colour
red.
Note: There are some commonly used attributes are given below, and the complete list and
explanation of all attributes are given in HTML attributes List.
https://www.javatpoint.com/html-attributes 4/12
5/2/24, 4:18 PM HTML Attributes - javatpoint
Example
With <h1> tag:
Test it Now
<p title="This is paragraph tag">Move the cursor over the heading and paragraph, and you will see
Test it Now
Code:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>
Test it Now
Output:
https://www.javatpoint.com/html-attributes 5/12
5/2/24, 4:18 PM HTML Attributes - javatpoint
Example
With link address:
Test it Now
https://www.javatpoint.com/html-attributes 6/12
5/2/24, 4:18 PM HTML Attributes - javatpoint
Test it Now
Example
Test it Now
Note: The above example also have height and width attribute, which define the height and width
of image on web page.
https://www.javatpoint.com/html-attributes 7/12
5/2/24, 4:18 PM HTML Attributes - javatpoint
Output:
Test it Now
IN HTML5, you can also omit use of quotes around attribute values.
https://www.javatpoint.com/html-attributes 8/12