🪟 Windows TippsThe Gemini desktop app is now available for Windows(11.09.2026 um 17:06 Uhr)
🕵️ SicherheitslückenBurn Out, Or Fade Away(14.09.2026 um 14:25 Uhr)
🪟 Windows TippsProfi-Edelstahlpfanne von WMF jetzt zum halben Preis erhältlich(15.09.2026 um 08:05 Uhr)
🪟 Windows TippsThe Gemini desktop app is now available for Windows(11.09.2026 um 17:06 Uhr)
🕵️ SicherheitslückenBurn Out, Or Fade Away(14.09.2026 um 14:25 Uhr)
🪟 Windows TippsProfi-Edelstahlpfanne von WMF jetzt zum halben Preis erhältlich(15.09.2026 um 08:05 Uhr)

🔧 Programmierung 🕛 vor 2 Jahren 6 Min Lesezeit
0

Write less CSS using :is(), :where(), and :has() pseudo-classes

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

CSS has evolved a lot over the years. It introduces many new powerful tools that make lives easier. From these tools, today I have picked three of them. We’ll see how :is(), :has(), and :where() pseudo-classes help simplify code, make it more readable, and reduce repetition.



This article teaches you, what, how, and why of :is(), :where(), and :has() pseudo-classes. You’ll see how we can use these pseudo-classes to design our website by writing less and more optimized code, which can be an excellent practice in software development.



As we will explore pseudo-classes, here is a basic overview in one sentence. In CSS pseudo-class is a rule that applies to an element based on a certain condition or state. Follow this link to



...






Explaining :where() pseudo-class



The :where() pseudo-class is very similar to :is(). We can group multiple selectors to reduce repetition in our code. It takes selectors as an argument. The major difference between :is() and :where() pseudo-class is that, :where() has zero specificity. This means it’s helpful when you want to style elements without adding extra weight to your CSS selector.



Style defined with :where() pseudo-class can be easily overridden. It means :where() does not add extra specificity in its selectors, and style inside :where() pseudo-class is based on selector’s own specificity.



The one good use-case for using :where() pseudo-class is to define the base style for multiple elements and you don’t want that style to affect any more specific rules that may override it later.



This way :where() allows you to apply styles without making your CSS too opinionated about which rules should win in a conflict.




CODE
/* Applying a default style */
:where(h1, p, a) {
color: red;
font-size: 20px;
}

/* More specific style */
a {
color: blue;
font-size: 16px;
}






In the above example, h1, p and a tags are provided as an argument to :where() pseudo-class for base styling. After that a tag which is used as a standalone tag with its styling can easily override the style defined in :where().



Like :is(), :where() is also supported in almost all major browsers. See an image below from caniuse.com to check supported browser versions:





In this example, you see I have created two div elements with the same .card class, in CSS by using :has() pseudo-class. By using the same .card with :has() pseudo-class, two conditions are given with different styling that you can able to see in the image output.



:has() is also supported in almost all major browsers. See an image below from caniuse.com to check supported browser versions:



. Read full article by following this link: write less CSS by using :is(), :where(), :has() pseudo-classes

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
The Gemini desktop app is now available for Windows
1 Quelle
Burn Out, Or Fade Away
1 Quelle
Windows 11 KB5129195 is out after Microsoft confirms major issues with the September 2026 update, but it won’t fix AMD GPU errors
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Write less CSS using :is(), :where(), and :has() pseudo-classes

Thematisch verwandte Begriffe: Write, less, using, where · 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 ...