HTML & CSS · Junior · Question 73 of 75

Which style wins: a rule in a stylesheet or the inline style attribute?

<p class="note" style="color: red">...</p>
<!-- CSS: .note { color: blue; } -->

Explanation

Inline styles beat any selector specificity. That's why they make overriding hard - prefer classes and keep inline styles for truly dynamic values.

Further reading

Problem with a question

HTML & CSS · Junior · question 73

Test yourself

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

Take this quiz