Recall & Review
beginner
What does the
:not() selector do in CSS?The
:not() selector selects all elements that do NOT match the selector inside the parentheses. It helps exclude specific elements from styling.Click to reveal answer
beginner
How would you select all
<p> elements except those with class highlight?Use
p:not(.highlight). This selects all paragraphs that do not have the class highlight.Click to reveal answer
intermediate
Can
:not() accept multiple selectors separated by commas?No. The
:not() selector accepts only a single simple selector. To exclude multiple selectors, chain multiple :not() selectors.Click to reveal answer
beginner
Example:
div:not(.active) - What does this select?It selects all <code>div</code> elements that do NOT have the class <code>active</code>. So any <code>div</code> without that class will be styled.Click to reveal answer
intermediate
Why use
:not() instead of just selecting what you want directly?Sometimes it’s easier to say "select everything except this" rather than listing all the things you want. It keeps CSS simpler and easier to maintain.
Click to reveal answer
What does
button:not(.disabled) select?✗ Incorrect
The
:not(.disabled) selects buttons that do NOT have the class disabled.Can
:not() contain multiple selectors separated by commas?✗ Incorrect
:not() accepts only one simple selector inside the parentheses.Which CSS rule excludes all
li elements with class special?✗ Incorrect
li:not(.special) selects all li elements except those with class special.What is the main benefit of using
:not()?✗ Incorrect
:not() helps exclude elements from being selected.Which selector selects all
input elements except those of type checkbox?✗ Incorrect
input:not([type=checkbox]) selects all inputs except checkboxes.Explain how the
:not() selector works and give a simple example.Think about selecting everything except something specific.
You got /3 concepts.
Describe a situation where using
:not() makes CSS easier to write.Imagine you want to style many items but skip a few.
You got /3 concepts.