0
0
CSSmarkup~5 mins

Not selector in CSS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AAll buttons with class disabled
BAll buttons without class disabled
CAll elements except buttons with class disabled
DOnly buttons with class disabled
Can :not() contain multiple selectors separated by commas?
ANo, only one simple selector is allowed
BYes, it accepts multiple selectors
CYes, but only if selectors are classes
DNo, it only works with IDs
Which CSS rule excludes all li elements with class special?
Ali:not(.special)
Bli:not#special
C:not(li.special)
Dli.special
What is the main benefit of using :not()?
ATo style all elements
BTo select elements with a specific class
CTo select only IDs
DTo exclude certain elements from selection
Which selector selects all input elements except those of type checkbox?
Ainput[type=checkbox]
Binput:checkbox
Cinput:not([type=checkbox])
Dinput:not(.checkbox)
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.