This content originally appeared on Envato Tuts+ Tutorials and was authored by Adi Purdila
In this video you’ll learn how to simplify your CSS code, turning long verbose selectors into something much more efficient with the :is()
and :where()
pseudo-classes.
For example, let’s say you use the following selectors to target a bunch of heading elements on the page and make them all serif:
header h1, header h2, header h3, main h1, main h2, main h3, aside h1, aside h2, aside h3 { font-family: serif; }
That’s quite messy. But using the :is()
pseudo class function we can change all that into this:
:is(header, main, aside) :is(h1, h2, h3) { font-family: serif; }
.That’s just one example. Check out the video to see more, along with explanations of how :is()
works, and how it goes hand in hand with the :where()
pseudo class too!
CSS Fan? Check Out These Videos!
If we haven’t met before my name’s Adi and I’m a web designer. It’s my goal with these videos to help you become a better web designer and developer!
- CSSExploring Creative CSS Hover Effects for Inline Links
- CSS Grid LayoutCSS Grid vs. Flexbox: Which Should You Use and When?
- CSSQuick tip: How to Make Elements Resizable with CSS Resize
- CSSBetter Focus Styles with CSS Pseudo-Class :focus-visible
Resources
- :is() (:matches(), :any()) - CSS: Cascading Style Sheets | MDN
- :where() - CSS: Cascading Style Sheets | MDN
- Understanding CSS Specificity
- :is() CSS pseudo-class | Can I use... Support tables for HTML5, CSS3, etc
- CSS selector:
:where()
| Can I use... Support tables for HTML5, CSS3, etc - Making Long Selectors Short with :is() and :where()
This content originally appeared on Envato Tuts+ Tutorials and was authored by Adi Purdila
Adi Purdila | Sciencx (2022-02-11T11:27:59+00:00) Super Short CSS Selectors With :is() and :where(). Retrieved from https://www.scien.cx/2022/02/11/super-short-css-selectors-with-is-and-where/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.