×

css · level 1 · unit 2 · lesson 4

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

When two rules disagree, the later one wins.

The browser reads rules from top to bottom. If two rules set the same property on the same element, the later one wins and overrides the first. This settling is called the .

Rules only clash over the same property. If one rule sets color and a later one sets background-color, there is no clash. The element gets both.

This explains a common puzzle: you change a colour and nothing happens. Look further down, because a later rule may be overriding yours.

<p>Which colour am I?</p>
p {
  color: blue;
}
p {
  color: red;
}

Press show my page to see it here.

Swap the two rules round and run it again to see blue win instead.