This page demonstrates the use of various CSS selectors. Each example is styled using demo.css.
This paragraph uses a class selector for styling.
This paragraph uses an ID selector for styling.
Hover over this link to see the :hover pseudo-class in action.
This paragraph has a ::before pseudo-element for decoration.
/* Class Selector */
.highlight {
background: #eaf6e6;
padding: 5px;
}
/* ID Selector */
#unique {
font-weight: bold;
color: #0056b3;
}
/* Attribute Selector */
a[title] {
color: #d63384;
text-decoration: underline;
}
/* Pseudo-Class Selector */
a:hover {
color: #0056b3;
font-weight: bold;
}
/* Pseudo-Element Selector */
.quote::before {
content: "“";
color: #0056b3;
font-size: 24px;
margin-right: 5px;
}