Recall & Review
beginner
Why does the order of CSS rules matter?
CSS rules are applied in the order they appear. Later rules can override earlier ones if they target the same elements with the same specificity.
Click to reveal answer
beginner
What happens if two CSS rules have the same selector but different property values?
The rule that comes last in the CSS file will be applied, overriding the earlier one.
Click to reveal answer
intermediate
How does CSS specificity interact with order?
If two rules have different specificity, the one with higher specificity wins, regardless of order. Order only matters when specificity is equal.
Click to reveal answer
intermediate
What is the 'cascade' in CSS?
The cascade is the process CSS uses to decide which styles apply when multiple rules target the same element. Order and specificity are key parts of the cascade.
Click to reveal answer
advanced
How can you ensure a CSS rule always applies regardless of order?
You can use the !important declaration to force a rule to apply, but it should be used sparingly as it can make debugging harder.
Click to reveal answer
If two CSS rules have the same selector and property, which one applies?
✗ Incorrect
When selectors and specificity are the same, the last rule in the CSS file applies.
What does CSS specificity affect?
✗ Incorrect
Specificity determines which CSS rule wins when multiple rules target the same element.
What is the effect of using !important in CSS?
✗ Incorrect
!important forces a CSS rule to apply over others, regardless of order or specificity.
If two rules have different specificity, which one applies?
✗ Incorrect
The rule with higher specificity applies, regardless of order.
Why is the order of CSS rules important?
✗ Incorrect
Later CSS rules can override earlier ones if selectors and specificity are the same.
Explain how CSS decides which style to apply when multiple rules target the same element.
Think about the cascade and how order and specificity work together.
You got /4 concepts.
Describe a real-life example where changing the order of CSS rules changes the look of a webpage.
Imagine you want to change a button color but your new rule doesn't work until you move it below the old one.
You got /4 concepts.