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
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.