Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 14, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 14, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 14, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 14, 2025

      I test a lot of AI coding tools, and this stunning new OpenAI release just saved me days of work

      May 14, 2025

      How to use your Android phone as a webcam when your laptop’s default won’t cut it

      May 14, 2025

      The 5 most customizable Linux desktop environments – when you want it your way

      May 14, 2025

      Gen AI use at work saps our motivation even as it boosts productivity, new research shows

      May 14, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Strategic Cloud Partner: Key to Business Success, Not Just Tech

      May 14, 2025
      Recent

      Strategic Cloud Partner: Key to Business Success, Not Just Tech

      May 14, 2025

      Perficient’s “What If? So What?” Podcast Wins Gold at the 2025 Hermes Creative Awards

      May 14, 2025

      PIM for Azure Resources

      May 14, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Windows 11 24H2’s Settings now bundles FAQs section to tell you more about your system

      May 14, 2025
      Recent

      Windows 11 24H2’s Settings now bundles FAQs section to tell you more about your system

      May 14, 2025

      You can now share an app/browser window with Copilot Vision to help you with different tasks

      May 14, 2025

      Microsoft will gradually retire SharePoint Alerts over the next two years

      May 14, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»Quick Reminder That :is() and :where() Are Basically the Same With One Key Difference

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

    March 20, 2025

    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, nav) :is(h1, h2, h3, h4, h5, h6) {
      color: #BADA55;
    }
    
    /* ... which would be the equivalent of: */
    section h1, section h2, section h3, section h4, section h5, section h6, 
    article h1, article h2, article h3, article h4, article h5, article h6, 
    aside h1, aside h2, aside h3, aside h4, aside h5, aside h6, 
    nav h1, nav h2, nav h3, nav h4, nav h5, nav h6 {
      color: #BADA55;
    }

    There’s just one catch: the specificity. The selector’s specificity matches the most specific selector in the function’s arguments. That’s not a big deal when working with a relatively flat style structure containing mostly element and class selectors, but if you toss an ID in there, then that’s the specificity you’re stuck with.

    /* Specificity: 0 0 1 */
    :is(h1, h2, h3, h4, h5, h6) {
      color: #BADA55;
    }
    
    /* Specificity: 1 0 0 */
    :is(h1, h2, h3, h4, h5, h6, #id) {
      color: #BADA55;
    }

    That can be a neat thing! For example, you might want to intentionally toss a made-up ID in there to force a style the same way you might do with the !important keyword.

    What if you don’t want that? Some articles suggest nesting selectors instead which is cool but not quite with the same nice writing ergonomics.

    There’s where I want to point to the :where() selector instead! It’s the exact same thing as :is() but without the specificity baggage. It always carries a specificity score of zero. You might even think of it as a sort of specificity reset.

    /* Specificity: 0 0 0 */
    :where(h1, h2, h3, h4, h5, h6) {
      color: #BADA55;
    }
    
    /* Specificity: 0 0 0 */
    :where(h1, h2, h3, h4, h5, h6, #id) {
      color: #BADA55;
    }

    So, is there a certain selector hijacking your :is() specificity? You might want :where() instead.


    Quick Reminder That :is() and :where() Are Basically the Same With One Key Difference originally published on CSS-Tricks, which is part of the DigitalOcean family. You should get the newsletter.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleWindows 11 File Explorer is about to get a speed boost
    Next Article World Water Day: how GitHub Copilot is helping bring clean water to communities

    Related Posts

    News & Updates

    I test a lot of AI coding tools, and this stunning new OpenAI release just saved me days of work

    May 14, 2025
    News & Updates

    How to use your Android phone as a webcam when your laptop’s default won’t cut it

    May 14, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    What Are Logs in Programming?

    Development

    FlipaClip animation app data breach exposes details of almost 900,000 users

    Development

    What is Project Strawberry? OpenAI’s mystery AI tool explained

    Development

    Ongoing Cyber Attacks Exploit Critical Vulnerabilities in Cisco Smart Licensing Utility

    Development
    Hostinger

    Highlights

    Pixel 9a details leak – how its specs compare to my Pixel 9 Pro

    February 19, 2025

    Google’s next phone release is coming soon, and a new leak contains plenty of very…

    How can I format the current date and time and then use them in a variable in GoTest?

    July 12, 2024

    Azure Access to Internal Selenium Server

    July 14, 2024
    A Code Implementation to Use Ollama through Google Colab and Building a Local RAG Pipeline on Using DeepSeek-R1 1.5B through Ollama, LangChain, FAISS, and ChromaDB for Q&A

    A Code Implementation to Use Ollama through Google Colab and Building a Local RAG Pipeline on Using DeepSeek-R1 1.5B through Ollama, LangChain, FAISS, and ChromaDB for Q&A

    April 8, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.