When you start learning HTML, the question what is an HTML attribute comes up very quickly. In simple terms, an attribute is extra information inside an HTML tag that helps define its behavior, appearance, or value.
Attributes make markup more flexible: they can add a link, a tooltip, alternative text for an image, or a technical identifier for styles and scripts.
What an HTML attribute means in simple terms
An HTML element consists of an opening tag, content, and a closing tag. The attribute is written inside the opening tag in the form name=”value”.
For example:
<a href=”https://example.com”>Go to site</a>
Here, a is the link element, and href is the attribute that specifies the destination. Without it, the tag would not know where to send the user.
How attribute syntax works
The basic rule is simple: write attributes after the tag name, and separate multiple attributes with spaces.
- One attribute: <img src=”photo.jpg”>
- Multiple attributes: <img src=”photo.jpg” alt=”Laptop photo”>
- An element with a class: <p class=”highlight”>Text</p>
Some attributes use quoted values, while others are boolean, meaning they are either present or absent. For example, disabled on a button simply turns it off:
<button disabled>Send</button>
Why attributes are needed
Attributes help HTML do more than display content — they describe it more precisely. That matters for websites, accessibility, and browser behavior.
The most common roles of attributes
- Define links: href in the a tag
- Connect files: src in img, script, and iframe
- Describe images: alt
- Help with styling: class and id
- Control behavior: target, disabled, readonly
For a browser, an attribute is a clue: how to display the element, how to interpret it, and how to interact with it.
Attributes beginners should know
If you are just getting started, pay attention to a few attributes that appear on almost every website.
- href — link address
- src — file path
- alt — alternative description of an image
- title — tooltip on hover
- class — CSS class
- id — unique element identifier
For example, alt is important not only for SEO but also for accessibility: it helps people who use screen readers understand what an image shows.
Common attribute mistakes
Beginners most often confuse an element name with an attribute or forget the quotes around a value. It is also worth checking that:
- the attribute is written in the correct tag;
- the value is not omitted without a good reason;
- the same id is not used on multiple elements;
- alt is not left empty unless there is a valid reason.
Another common mistake is adding attributes “just in case.” It is better to use only the ones that really change the behavior or description of an element.
Summary
What is an HTML attribute? It is an extra setting for an element that clarifies its content, appearance, or function. Attributes make markup more useful, easier for browsers to understand, and more convenient for styles, scripts, and users.

