Attributes tell elements how to behave.
Direct answer
HTML attributes add information to elements, such as where a link goes (href), which image to show (src), a description of an image (alt) and names for styling or scripting (class and id). Write them inside the opening tag as name="value".
Common attributes
| Attribute | Used on | Purpose |
|---|---|---|
href | a | link destination |
src | img, script | file source |
alt | img | text alternative |
class | any | group for styling |
id | any | unique identifier |
type | input, button | kind of control |
placeholder | input | hint text |
required | input | must be filled |
target | a | where to open the link |
data-* | any | store custom data |
Examples
<a href="/about" target="_blank" rel="noopener">About</a>
<img src="team.jpg" alt="Our team at the launch event" width="600" height="400">
<input type="email" placeholder="you@example.com" required>
<button data-action="save">Save</button>
Good habits
- Always write meaningful
alttext, oralt=""for decorative images. - Add
rel="noopener"withtarget="_blank". - Use lowercase and quote values.
Where Teyro fits
Teyro's HTML & CSS for Beginners course turns this into short lessons you can play in a few minutes a day. It has 100 lessons, and you can start free.
The bottom line
Attributes are the settings of HTML. Learn the common ones and the rest is lookup.



