Challenge - 5 Problems
CSS Precedence Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Which CSS rule has the highest precedence?
Consider a paragraph with the following CSS rules applied:
1. An external stylesheet sets
2. An internal <style> block sets
3. An inline style sets
What color will the paragraph text be?
1. An external stylesheet sets
color: blue;.2. An internal <style> block sets
color: green;.3. An inline style sets
color: red;.What color will the paragraph text be?
CSS
<p style="color: red;">This is a test paragraph.</p>Attempts:
2 left
💡 Hint
Think about where the style is written and how CSS decides which rule to use.
✗ Incorrect
Inline styles have the highest precedence over internal and external stylesheets. So the text color will be red.
📝 Syntax
intermediate2:00remaining
What color will this paragraph be?
Given this HTML and CSS:
And this external CSS:
What color will the text be?
<p id="text" style="color: orange;">Hello</p>And this external CSS:
#text { color: purple !important; }What color will the text be?
CSS
<p id="text" style="color: orange;">Hello</p>
Attempts:
2 left
💡 Hint
Remember what
!important does in CSS.✗ Incorrect
The
!important rule overrides inline styles, so the text color will be purple.❓ rendering
advanced2:00remaining
What color will the text appear?
Look at this HTML snippet:
And this CSS:
What color will the <p> text be?
<div style="color: green;"><p class="text">Sample Text</p></div>And this CSS:
.text { color: blue !important; }What color will the <p> text be?
CSS
<div style="color: green;"><p class="text">Sample Text</p></div>
Attempts:
2 left
💡 Hint
Think about how
!important affects inheritance and specificity.✗ Incorrect
The class selector with
!important on the <p> overrides the inherited inline style from the parent div, so the text is blue.❓ selector
advanced2:00remaining
Which CSS rule applies to the button's background?
Given this HTML:
And these CSS rules:
What background color will the button have?
<button id="btn" style="background-color: yellow;">Click</button>And these CSS rules:
#btn { background-color: red !important; }button { background-color: blue; }What background color will the button have?
CSS
<button id="btn" style="background-color: yellow;">Click</button>
Attempts:
2 left
💡 Hint
Check which rule has the highest specificity and if !important is used.
✗ Incorrect
The ID selector with
!important overrides the inline style, so the button background is red.❓ accessibility
expert2:00remaining
How does inline style affect accessibility and user preferences?
If a website uses inline styles to set text color and background color directly on elements, what is a potential accessibility problem?
Choose the best answer.
Choose the best answer.
Attempts:
2 left
💡 Hint
Think about how users customize their browsers for better visibility.
✗ Incorrect
Inline styles hard-code colors, which can prevent users from applying their own color schemes or high contrast modes, reducing accessibility.