Skip to main content
CSS-Tricks
Since 2007
  • Articles
  • Guides
  • Almanac
  • Links
  • Picks
  • Newsletter
  • Search

Articles Tagged
selectors

22 Articles
{
,

}
Syntax for CSS prefix selector, which is a dash and asterisk.
Direct link to the article Resolved: CSS Class Prefix Selector
selectors

Resolved: CSS Class Prefix Selector

A newly resolved proposal would allow us to select classes that are a prefix for variations with a wildcard, like .prefix-*.
Image
Geoff Graham on Aug 21, 2026
Image
Direct link to the article The Different Ways to Select <html> in CSS
selectors

The Different Ways to Select <html> in CSS

Sure, we can select the <html> element in CSS with, you know, a simple element selector, html. But what other (trivial and perhaps useless) ways can we do it?
Image
Daniel Schwarz on Mar 5, 2026
Image
Direct link to the article Should We Even Have :closed?
csswg selectors

Should We Even Have :closed?

Is there really a difference between using :not(:open) and :closed? As always, it depends. Sunkanmi Fafowora explains why :closed is currently not a thing.
Image
Sunkanmi Fafowora on Nov 20, 2025
Image
Direct link to the article Quick Reminder That :is() and :where() Are Basically the Same With One Key Difference
selectors specificity

Quick Reminder That :is() and :where() Are Basically the Same With One Key Difference

I’ve seen a handful of recent posts talking about the utility of the :is() relational pseudo-selector. No need to delve into the details other than to say it can help make compound selectors a lot more readable.

:is(section, article, aside, 
…
Image
Geoff Graham on Mar 20, 2025
Image
Direct link to the article Chained
selectors

Chained

It’s possible to combine selectors to share the same set of styles. All we do is separate each selector with a comma, known as chaining selectors.

.selector-1,
.selector-2,
.selector-3 {
  /* We share these styles! 🤗 */
}
…
Image
Geoff Graham on Dec 16, 2024
Image
Direct link to the article Select the Previous Sibling
selectors

Select the Previous Sibling

.element:hover:has(+ & + *) { /* styles */ }

A really handy recipe from Chris that is a perfect use case for the :has() selector. Say we have a series of card components in a row. And when one card …

Image
Geoff Graham on Sep 18, 2024
Image
Direct link to the article CSS Selectors
selectors

CSS Selectors

A complete guide covering all of the various methods we have to select elements in CSS and how to use them for applying styles.
Image
Geoff Graham on Jul 15, 2024
Image
Direct link to the article “If” CSS Gets Inline Conditionals
custom properties selectors

“If” CSS Gets Inline Conditionals

A few sirens went off a couple of weeks ago when the CSS Working Group (CSSWG) resolved to add an if() conditional to the CSS Values Module Level 5 specification. It was Lea Verou’s X post that same day that …

Image
Geoff Graham on Jul 9, 2024
Image
Direct link to the article Case-Sensitive Selectors
selectors

Case-Sensitive Selectors

/* Case sensitive */
a[href*='css-tricks' s] {}

/* Case insensitive */
a[href*='css-tricks' i] {}

Adding an s makes the selector case-sensitive and i makes it case-insensitive.

Source…
Image
Geoff Graham on May 22, 2024
Image
Direct link to the article @supports selector()
:where @supports cross-browser selectors

@supports selector()

I didn’t realize the support for @supports determining selector support was so good! I usually think of @supports as a way to test for property: value pair support. But with the selector() function, we can test for selector support …

Image
Chris Coyier on Oct 19, 2021
  • 1
  • 2
  • 3
  • Older Image

CSS-Tricks is powered by DigitalOcean.

Get Curated Front-End Roundups Right in Your Inbox

Coming back really, really soon! See past issues →

CSS-Tricks
  • About the site
  • Contact us
  • Write for CSS-Tricks!
  • Advertising
  • RSS Feeds
Social
  • Bluesky
  • Mastodon
  • CodePen
  • X / Twitter
  • LinkedIn
Legalese
  • CSS-Tricks License
  • AI Statement
Back to Top
Advertisement
Advertisement