Building Your Learning Module...
Getting things ready for you!
Find videos you like?
Save to resource drawer for future reference!
h1 {
color: blue;
font-size: 32px;
text-align: center;
}This rule styles all <h1> elements with blue color, 32px size, and centered alignment.
Targets all elements of a specific type
p { ... }Targets elements with specific class
.button { ... }Targets a single unique element
#header { ... }pSelects all elements of that type
All paragraphs
.cardSelects elements with that class
Elements with class="card"
#logoSelects the unique element with that ID
Element with id="logo"
*Selects all elements on the page
Every single element
div, p, h1Selects multiple different elements
All divs, paragraphs, and h1s
div pSelects elements inside other elements
Paragraphs inside divs
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<div class="container">
<h2>🎯 CSS Selectors Demo</h2>
<p>
Regular paragraph styled with element selector
<span class="label label-element">p selector</span>
</p>
<p class="highlight">
Paragraph with class styled using class selector
<span class="label label-class">.highlight</span>
</p>
<p>
Another regular paragraph with element selector
<span class="label label-element">p selector</span>
</p>
<p id="special">
Unique paragraph with ID styled using ID selector
<span class="label label-id">#special</span>
</p>
</div>
</body>
</html>Loading preview...
When multiple selectors target the same element, CSS uses specificity to determine which styles apply. More specific selectors override less specific ones.
Highest priority - most specific
#headerMedium priority
.buttonLowest priority - least specific
p