HTML & CSS · Middle · Question 45 of 75

A React component merges external classes: className={"p-2 " + props.className}, and receives p-4. What padding results?

Explanation

Class order in the class attribute doesn't affect the cascade: with equal specificity, the rule that comes later in the CSS file wins. So the outcome of p-2 p-4 is unpredictable from the component's point of view. tailwind-merge (often via a cn() helper) removes conflicting classes and keeps the last one.

Further reading

Problem with a question

HTML & CSS · Middle · question 45

Test yourself

Take the HTML & CSS · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz