HTML/CSSQuestion 10 of 14
CSS selectors
Answer out loud or in your head first, then compare.
Answer
A selector determines which elements a rule applies to.
CSS
button { font: inherit; } /* type */
.primary { color: blue; } /* class */
#menu { padding: 16px; } /* id */
input[required] { border: 1px solid; }
.card > p { margin: 0; } /* direct child */
nav a { text-decoration: none; } /* descendant */To be precise: when rules conflict, the cascade decides. Origin, importance, layers, specificity and order all matter.
Pitfall: “the last rule always wins” is a simplification. I avoid stacking ID selectors and !important as a fix for every conflict.
How did it go? Be honest — “Not yet” puts the question on your review list.