0
0
CSSmarkup~20 mins

!important usage in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Important CSS Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What does !important do in CSS?
Consider the CSS rule color: red !important;. What effect does !important have on this style declaration?
AIt makes the style apply only when the user hovers over the element.
BIt disables the style so it won't apply to the element.
CIt only applies the style if the element has a class named <code>important</code>.
DIt makes the style override other conflicting styles, even inline styles without <code>!important</code>.
Attempts:
2 left
💡 Hint
Think about how CSS decides which style wins when multiple rules apply.
📝 Syntax
intermediate
1:00remaining
Which CSS rule correctly uses !important?
Select the CSS rule that correctly applies !important to the background-color property.
Abackground-color: blue !important;
Bbackground-color: !important blue;
Cbackground-color !important: blue;
Dbackground-color: blue important!;
Attempts:
2 left
💡 Hint
Remember the order: property, colon, value, then !important.
rendering
advanced
1:30remaining
What color will the text be?
Given the HTML and CSS below, what color will the paragraph text appear as in the browser?

<style> p { color: green !important; } #special { color: red; } </style> <p id="special">Hello!</p>
CSS
<style>
p { color: green !important; }
#special { color: red; }
</style>
<p id="special">Hello!</p>
ARed
BGreen
CBlack (default)
DBlue
Attempts:
2 left
💡 Hint
Which rule has higher priority, the one with !important or the ID selector without it?
selector
advanced
1:30remaining
Which selector's !important style applies?
Consider these CSS rules:

.box { border: 1px solid black !important; } #unique { border: 2px dashed red !important; }

Which border style will an element with class="box" and id="unique" have?
CSS
.box { border: 1px solid black !important; }
#unique { border: 2px dashed red !important; }
ANo border because of conflicting !important rules
B1px solid black border from .box
C2px dashed red border from #unique
DDefault border (none) because !important cancels out
Attempts:
2 left
💡 Hint
When multiple !important rules apply, which selector wins?
accessibility
expert
2:00remaining
Why should !important be used carefully for accessibility?
Using !important can sometimes harm accessibility. Which reason below best explains why?
AIt can override user styles or browser settings that help users with disabilities.
BIt makes the page load slower, causing delays for screen readers.
CIt disables keyboard navigation on the page.
DIt hides content from assistive technologies.
Attempts:
2 left
💡 Hint
Think about how users might customize styles for better reading.