Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Sichere ProgrammierungA PASS over an empty set is the same string as a real pass(21.09.2026 um 01:08 Uhr)
Sichere ProgrammierungThe Commit That Wouldn’t Merge(21.09.2026 um 01:23 Uhr)
Sichere ProgrammierungWebRTC at Scale(21.09.2026 um 01:35 Uhr)
Sichere ProgrammierungSemantic Versioning (SemVer): Why Version Numbers Have Three Parts(21.09.2026 um 01:40 Uhr)
Sichere ProgrammierungWhat If AI Works Too Well?(21.09.2026 um 01:46 Uhr)
Sichere ProgrammierungA PASS over an empty set is the same string as a real pass(21.09.2026 um 01:08 Uhr)
Sichere ProgrammierungThe Commit That Wouldn’t Merge(21.09.2026 um 01:23 Uhr)
Sichere ProgrammierungWebRTC at Scale(21.09.2026 um 01:35 Uhr)
Sichere ProgrammierungSemantic Versioning (SemVer): Why Version Numbers Have Three Parts(21.09.2026 um 01:40 Uhr)
Sichere ProgrammierungWhat If AI Works Too Well?(21.09.2026 um 01:46 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

The Ultimate CSS Selectors Cheat Sheet 2025

Reagiere als Erste:r — dein Feedback zählt!

A complete guide to CSS selectors with examples — from basics to advanced pseudo-classes and pseudo-elements.

CSS selectors are the building blocks of styling. They let you target specific elements on your page and apply styles in powerful ways.

In this article, we’ll go through every CSS selector with examples — from the basics you already know to the advanced ones that will make your CSS sharper and cleaner.

🔹 1. Basic Selectors

These are the most common selectors you'll use every day.

Selector Description Example
* Universal selector – selects all elements * { margin: 0; }
element Type selector – selects all <p> elements p { color: blue; }
.class Class selector .btn { background: green; }
#id ID selector #header { height: 80px; }

🔹 2. Grouping & Combinators

Selectors can be combined to target elements more precisely.

Selector Description Example
A, B Groups multiple selectors h1, h2 { font-weight: bold; }
A B Descendant – selects B inside A div p { color: red; }
A > B Child – selects direct children ul > li { list-style: none; }
A + B Adjacent sibling – selects next sibling h1 + p { font-size: 14px; }
A ~ B General sibling – selects all siblings h1 ~ p { color: gray; }

🔹 3. Attribute Selectors

Target elements based on attributes (super handy for forms & links).

Selector Description Example
[attr] Elements with attribute [title] { color: green; }
[attr="value"] Exact match input[type="text"] { border: 1px solid; }
[attr~="value"] Contains word [class~="active"] { color: red; }
[attr|="value"] Starts with value (or value-) [lang|="en"] { font-style: italic; }
[attr^="value"] Starts with value a[href^="https"] { color: blue; }
[attr$="value"] Ends with value img[src$=".png"] { border: 1px solid; }
[attr*="value"] Contains value a[href*="login"] { color: red; }

🔹 4. Pseudo-classes

These selectors apply styles based on state or position.

Selector Description Example
:hover On hover button:hover { background: orange; }
:focus On focus input:focus { border: 2px solid blue; }
:active On active click a:active { color: red; }
:visited Visited link a:visited { color: purple; }
:first-child First child of parent p:first-child { font-weight: bold; }
:last-child Last child of parent p:last-child { color: gray; }
:nth-child(n) Matches based on position li:nth-child(2) { color: red; }
:only-child When element is only child p:only-child { font-size: 20px; }
:not(selector) Excludes selector div:not(.active) { opacity: 0.5; }
:checked Checked inputs input:checked { accent-color: red; }
:disabled Disabled inputs input:disabled { opacity: 0.5; }
:required Required inputs input:required { border-color: red; }

🔹 5. Pseudo-elements

Pseudo-elements let you style parts of an element.

Selector Description Example
::before Inserts content before element p::before { content: "👉 "; }
::after Inserts content after element p::after { content: " ✅"; }
::first-letter Styles first letter p::first-letter { font-size: 200%; }
::first-line Styles first line p::first-line { color: red; }
::selection Styles selected text ::selection { background: yellow; }
::placeholder Styles input placeholder input::placeholder { color: gray; }
::marker Styles list markers li::marker { color: red; }

🔹 6. Advanced & UI States

These are less common but very powerful.

Selector Description Example
:root Root element (<html>) :root { --main-color: blue; }
:target Active anchor target #section:target { background: yellow; }
:in-range Input value in range input:in-range { border-color: green; }
:out-of-range Input value out of range input:out-of-range { border-color: red; }
:read-only Read-only inputs input:read-only { background: lightgray; }
:read-write Editable inputs input:read-write { background: white; }
:fullscreen Fullscreen mode :fullscreen { background: black; }

🖥 Example in Action


html
<!DOCTYPE html>
<html>
<head>
  <style>
    p:first-child { color: blue; }
    ul > li { font-weight: bold; }
    a[href^="https"] { color: green; }
    button:hover { background: orange; }
    p::after { content: " ✅"; }
  </style>
</head>
<body>
  <p>First paragraph</p>
  <p>Second paragraph</p>
  <ul>
    <li>List item</li>
  </ul>
  <a href="https://example.com">Secure Link</a>
  <button>Click Me</button>
</body>
</html>
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten The Ultimate CSS Selectors Cheat Sheet 2025

Thematisch verwandte Begriffe: Ultimate, Selectors, Cheat, Sheet · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-93960 | A vulnerability was identified in Pixelfed up to 0.12.11. Impacted is th…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick