Basic Selectors
An element selector targets a tag (p). A class selector starts with a dot (.card) and targets every element carrying that class. An id selector starts with # and targets the one element with that id.
Prefer classes for styling. Ids must be unique on a page and they are harder to override later.
Example
<style>
p { color: gray; }
.highlight { background: yellow; }
#title { font-size: 28px; }
</style>
<p id="title">Title</p>
<p class="highlight">Highlighted text</p>
<p>Normal text</p>Exercise
Select every element that has class "note".
note {
color: red;
}Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.