Starlit Daily

📚 › HTML: build the structure of a web page

10. Attributes: id, class and data

An attribute adds information to an element inside its start tag. id gives one element a unique name on the page. class groups elements that share a style. data-* attributes store your own values.

CSS and JavaScript use these attributes to find and change elements.

Show example

<p id="intro" class="note" data-level="easy">Start here.</p>

✍️ Your turn

Make a paragraph with id main-text, class highlight, and data-level set to beginner.

← Back to course