Comments on: Is “is” Useful? https://css-tricks.com/is-is-useful/ Tips, Tricks, and Techniques on using Cascading Style Sheets. Thu, 09 Jan 2020 20:48:27 +0000 hourly 1 https://wordpress.org/?v=6.1.1 By: Laurie Jones https://css-tricks.com/is-is-useful/#comment-1753603 Thu, 09 Jan 2020 20:48:27 +0000 https://css-tricks.com/?p=300774#comment-1753603 Thanks Chris! I thought it was funny that the example from MDN still had the three rules defined and not just this:

:is(ol, ul, menu, dir) :is(ol, ul, menu, dir) :is(ul, menu, dir) {
  list-style-type: square;
}

But clicking through to the MDN page they explicitly call this out as slow, and advise not to use :is() for the rightmost selector. Something I’ll have to keep in mind, I guess.

]]>
By: roberto https://css-tricks.com/is-is-useful/#comment-1753519 Mon, 06 Jan 2020 22:52:32 +0000 https://css-tricks.com/?p=300774#comment-1753519 In reply to rzxrzx.

.item1,.item2{ color: “black” } what different ? I don’t understand.

]]>
By: Yexan https://css-tricks.com/is-is-useful/#comment-1753505 Mon, 06 Jan 2020 13:01:55 +0000 https://css-tricks.com/?p=300774#comment-1753505 Thanks Chris for the article.

It reminds me when we use to declare placeholders like :

::-webkit-input-placeholder { /* Chrome/Opera/Safari */
  color: pink;
}
::-moz-placeholder { /* Firefox 19+ */
  color: pink;
}
:-ms-input-placeholder { /* IE 10+ */
  color: pink;
}
:-moz-placeholder { /* Firefox 18- */
  color: pink;
}

If we grouped all the browser specific selectors in the same rules like

::-webkit-input-placeholder,
::-moz-placeholder,
:-ms-input-placeholder,
:-moz-placeholder { 
  color: pink;
}

It would invalidate the whole block. :D

Nice feature by the way, even if I still prefer to use SASS :)

ol, ul, menu, dir
  ol, ul, menu, dir
    ul, menu, dir
      list-style-type: square
]]>
By: Chris Coyier https://css-tricks.com/is-is-useful/#comment-1753491 Sun, 05 Jan 2020 17:57:09 +0000 https://css-tricks.com/?p=300774#comment-1753491 In reply to Dalibor Sojic.

I think this goes into the category of don’t worry about it. CSS selector performance is almost never a big deal (I’ve never optimized for it in, say, 20 years) unless you’re in a very very intense DOM situation (say rendering a million nodes). MDN does have a note how :-moz-any had bad performance in that it was the same as *, which personally I use willy nilly, and that :is aims to fix that “bad” performance.

]]>
By: tombakerim https://css-tricks.com/is-is-useful/#comment-1753484 Sun, 05 Jan 2020 08:54:35 +0000 https://css-tricks.com/?p=300774#comment-1753484 Can you please explain in detail like you are explaining it to someone hearing this concept for the first time ever.

]]>
By: rzxrzx https://css-tricks.com/is-is-useful/#comment-1753478 Sat, 04 Jan 2020 19:08:39 +0000 https://css-tricks.com/?p=300774#comment-1753478 :is(item1, item2, .... ) { color: "black" }

basically means match anything within the parentheses, it will match / translate to:

item1 { color: "black"}
item2 { color: "black"}
... { color: "black"} 

It’s like inArray() function, for CSS.
Really neat stuff that CSS deserve.

]]>
By: Grant https://css-tricks.com/is-is-useful/#comment-1753477 Sat, 04 Jan 2020 17:36:03 +0000 https://css-tricks.com/?p=300774#comment-1753477 The MDN example could be further simplified with an :is(ul, menu, dir)

]]>
By: Dalibor Sojic https://css-tricks.com/is-is-useful/#comment-1753476 Sat, 04 Jan 2020 16:59:28 +0000 https://css-tricks.com/?p=300774#comment-1753476 How about performance? Is “is” slower?

]]>
By: aror https://css-tricks.com/is-is-useful/#comment-1753473 Sat, 04 Jan 2020 09:41:12 +0000 https://css-tricks.com/?p=300774#comment-1753473 In reply to Ramesh.

Arent you missing h1?

]]>
By: Kuba https://css-tricks.com/is-is-useful/#comment-1753472 Sat, 04 Jan 2020 09:28:49 +0000 https://css-tricks.com/?p=300774#comment-1753472 Assuming the MDN example, how performant is :is() over the series of explicit selectors?

]]>
By: Ian https://css-tricks.com/is-is-useful/#comment-1753470 Sat, 04 Jan 2020 05:20:43 +0000 https://css-tricks.com/?p=300774#comment-1753470 Personally, I don’t remember needing a selector like :is(), while I have encountered several cases in which a selector like :has() could really come in handy.

]]>
By: Troy https://css-tricks.com/is-is-useful/#comment-1753469 Sat, 04 Jan 2020 01:20:59 +0000 https://css-tricks.com/?p=300774#comment-1753469 Learnt something new today. Didn’t even know about this CSS selector. Thanks for the quick and easy to understand examples.

]]>
By: John https://css-tricks.com/is-is-useful/#comment-1753466 Fri, 03 Jan 2020 21:20:33 +0000 https://css-tricks.com/?p=300774#comment-1753466 In reply to Ramesh.

Here’s a simplified example:

section section h1, section article h1 { ... } is the same as section *:is(section, article) { ... }

So it’s basically the same as an OR statement. (Also note that I added a * to make the example more clear.)

]]>
By: Ramesh https://css-tricks.com/is-is-useful/#comment-1753465 Fri, 03 Jan 2020 18:47:59 +0000 https://css-tricks.com/?p=300774#comment-1753465 I saw Adam’s tweet back then but couldn’t understand what :is() is doing and even here all those examples aren’t helping much. I am seriously not getting how
:is(section, article, aside, nav)
:is(section, article, aside, nav) {
font-size: 20px;
}

is equivalent to code shown! Can you please explain in detail like you are explaining it to someone hearing this concept for the first time ever. Thanks

]]>
By: Noah https://css-tricks.com/is-is-useful/#comment-1753462 Fri, 03 Jan 2020 17:14:13 +0000 https://css-tricks.com/?p=300774#comment-1753462 Great demonstration, I totally understand :is now! It’s extra weight if you’re using a compiler, but for vanilla CSS this would be a huge bonus to readability

]]>