Twitter | Search | |
Max Stoiber 🐟
How well do you know CSS? πŸ‘¨πŸΌβ€πŸ« Given these classes: .red { color: red; } .blue { color: blue; } Which color would these divs be? <div class="red blue"> <div class="blue red">
Reply Retweet Like More
Max Stoiber 🐟 31 Jan 19
Replying to @mxstbr
Reply Retweet Like
Harrison 7 Sep 18
Replying to @mxstbr
They’d both be blue given prioritisation is top to bottom? If class name index has an affect this is news to me.
Reply Retweet Like
Robert Schaap 7 Sep 18
Exactly, order of the tags on the div doesn't matter. Since they both have the same specificity, order determines the outcome and blue is declared last so it wins.
Reply Retweet Like
Markus Guenther 7 Sep 18
Replying to @mxstbr
Should be always blue...
Reply Retweet Like
useGetDerivedStateFromProps('Vince Picone') 7 Sep 18
Replying to @mxstbr
Trick question, the divs wouldn’t change color their text would. *hand-waving because I’m not sure*
Reply Retweet Like
Tobias Skarhed 7 Sep 18
Replying to @mxstbr
My thought exactly ;)
Reply Retweet Like
Michiel Sikma πŸ³οΈβ€πŸŒˆ 7 Sep 18
Replying to @mxstbr
Both blue, order of class names given to an html element doesn't matter, but the .blue rule overrides the .red rule due to appearing later in the CSS file and having the same specificity.
Reply Retweet Like
Innocent Amadi 7 Sep 18
Replying to @michielsikma @mxstbr
Exactly.
Reply Retweet Like