Search pages
Search all CSS Showcase pages by name
Advanced CSS Techniques
Master powerful selectors, pseudo-elements, CSS counters, and specificity management to write sophisticated, maintainable stylesheets.
Modern Complex Selectors
CSS has evolved with powerful new selectors that make targeting elements easier and more maintainable. Explore :is(), :where(), and :not().
Heading in Section
Heading in Article
Heading in Aside
Specificity Tip
:is() takes the specificity of its most specific argument, while :where() always has zero specificity. Use :where() for reusable base styles and :is() when you need more control.
Pseudo-elements Deep Dive
Pseudo-elements let you style specific parts of an element or add decorative content without extra HTML. They're your secret weapon for clean, semantic markup.
Once upon a time, in a web far, far away, there lived a developer who discovered the magic of CSS pseudo-elements. With just a few lines of code, entire design systems came to life, creating beautiful typography without touching a single line of HTML.
Try selecting this text — notice the custom selection colour! This works on any text element and can match your brand colours.
CSS Counters
CSS counters let you create automatic numbering without JavaScript. Perfect for step-by-step guides, nested lists, and numbered sections.
Attribute Selectors
Target elements based on their attributes and attribute values. Incredibly powerful for styling forms, links, and dynamic content.
Attribute Selector Operators
^= starts with, $= ends with, *= contains, ~= word match, |= starts with (dash-separated). These operators make attribute selectors incredibly flexible!
Combinators & Relationship Selectors
Combinators let you select elements based on their relationship to other elements. Master these and you'll write cleaner, more maintainable CSS.
Styled paragraph
Nested styled paragraph
Direct child (styled)
Grandchild (not styled)
Direct child (styled)
Heading
First paragraph (adjacent to h4)
Second paragraph (general sibling)
Third paragraph (general sibling)
Understanding & Managing Specificity
Specificity determines which CSS rules win when multiple rules target the same element. Master it to avoid !important hell.
Good
.button { }
.button-primary { }
.button-large { }Avoid
#header div.nav ul li a.button { }
.button { color: blue !important; }Specificity Tips
1. Prefer classes over IDs for styling
2. Keep selector chains short (2–3 levels max)
3. Use :where() for zero-specificity base styles
4. Avoid !important unless absolutely necessary
5. Organise CSS from low to high specificity
Best Practices
Key principles for writing advanced, maintainable CSS.
Keep Specificity Low
Use classes for styling, reserve IDs for JavaScript hooks. Flat selectors are easier to maintain and override.
Use Modern Selectors
Embrace :is(), :where(), and :has() to write cleaner, more maintainable selectors.
Leverage Pseudo-elements
Use ::before and ::after for decorative content instead of adding extra HTML elements.