*
* { margin: 0; }
element
p { color: blue; }
#id
#header { font-size: 20px; }
.class
.active { background: red; }
selector1, selector2
h1, h2 { color: green; }
selector1 selector2
div p { margin: 10px; }
selector1 > selector2
ul > li { list-style: none; }
selector1 + selector2
h1 + p { font-weight: bold; }
selector1 ~ selector2
h1 ~ p { color: gray; }
[attribute]
[type] { border: 1px solid; }
[attribute=value]
[type="text"] { width: 100%; }
[attribute~=value]
[class~="btn"] { padding: 10px; }
[attribute^=value]
[href^="https"] { color: blue; }
[attribute$=value]
[src$=".png"] { width: 200px; }
[attribute*=value]
[title*="error"] { color: red; }
:hover
button:hover { background: yellow; }
:focus
input:focus { outline: 2px solid; }
:active
a:active { color: orange; }
:nth-child(n)
li:nth-child(2) { color: red; }
:nth-of-type(n)
p:nth-of-type(1) { font-size: 20px; }
:first-child
li:first-child { font-weight: bold; }
:last-child
li:last-child { color: green; }
:only-child
div:only-child { padding: 10px; }
:first-of-type
h1:first-of-type { margin: 0; }
:last-of-type
p:last-of-type { color: purple; }
:only-of-type
h2:only-of-type { text-align: center; }
:not(selector)
div:not(.active) { opacity: 0.5; }
:checked
input:checked { background: blue; }
:disabled
button:disabled { opacity: 0.5; }
:enabled
button:enabled { cursor: pointer; }
:empty
div:empty { display: none; }
:root
:root { --main-color: blue; }
:target
#section:target { border: 2px solid; }
::before
p::before { content: "Note: "; }
::after
p::after { content: " End"; }
::first-letter
p::first-letter { font-size: 20px; }
::first-line
p::first-line { color: gray; }
::selection
::selection { background: yellow; }
::placeholder
input::placeholder { color: gray; }
::marker
li::marker { color: red; }
:lang(language)
p:lang(en) { font-style: italic; }
:has(selector)
div:has(img) { border: 1px solid; }
:is(selector)
:is(h1, h2) { margin: 0; }
:where(selector)
:where(h1, h2) { padding: 0; }
:any-link
:any-link { color: blue; }
:current
nav :current { font-weight: bold; }
:scope
:scope p { color: red; }
All CSS Selectors You Need, Explained with Examples
Quickly find and understand CSS selectors—ID, class, group selectors, and more—with clear descriptions and practical examples. Save time and code efficiently with SelectorForge!
Scroll Down
What You’ll Find Here
Our Mission
At SelectorForge, our mission is simple: to provide developers with a straightforward, accessible, and highly effective reference for CSS selectors. We understand that CSS can be daunting at times, especially when it comes to understanding the different types of selectors and their proper use. That’s why we’ve built a clean, modern interface that makes learning and implementing CSS selectors quick and easy.
We focus on providing a curated list of CSS selectors, from basic ones like the id and class selectors to more advanced group selectors and pseudo-classes. Each selector comes with a detailed description and practical examples to ensure you understand exactly how to implement them in your projects.