Courses / HTML
Free Beginner Web Development

HTML & Web Foundations

Learn how websites are structured from the ground up using HTML. Build real pages while learning elements, attributes, links, images, forms, tables, semantic HTML and more.

24
Lessons
4 Weeks
Duration
58%
Progress

Lesson 15 of 24

14 min learning time

IDs and Classes

The id attribute

An id identifies a specific element on a page and should normally be unique within that document.

The class attribute

A class can be shared by multiple elements and is commonly used for styling and JavaScript selection.

Example HTML
<h1 id="page-title">
    Vinsoft Lab
</h1>

<p class="description">
    Learn technology.
</p>

<p class="description">
    Build useful projects.
</p>

Practical Exercise

Build it yourself

Create one element with an id and two elements sharing the same class.

Quick Check

Test your understanding

Which attribute is commonly shared by multiple elements?