What is an attribute in HTML?

An attribute gives extra information about an HTML element. It is written inside the opening tag as name="value".

<a href="https://example.com" target="_blank">Visit</a>
<img src="photo.jpg" alt="A photo" width="200">

Here href, target, src, alt and width are attributes. Some common ones are id, class, style and title. Boolean attributes like disabled and required have no value. See HTML Attributes.


Learn more about the similar topics:
Tutorials
List of common HTML Tags
HTML Elements and Tags
HTML Attributes
HTML Block and Inline Elements
HTML Div and Span
HTML Class and ID
Exercises & Assignments
No Content Found.
Interview Questions & Answers
Do all HTML tags require both a begin and end tag?
What is the difference between HTML tags and elements?
What is an attribute in HTML?
What is the difference between DIV, SPAN and paragraph tag in HTML?
What is the difference between inline and block elements in HTML?
What are void (empty) elements in HTML?
What is the difference between id and class in HTML?