Conflicting css property resolve order


#1

So the id attribute has a higher hierarchy than the class attribute in CSS?


FAQ: Learn CSS Selectors Visual Rules - CSS Setup Selectors - ID Name
#2

Take a look at the code:

<p class="x" id="y">color</p>
#y {
  color: red;
}
.x {
  color: blue;
}

what color do you think the paragraph will be?

red, the id is higher in hierachy

now, to prove that this is actually true, look at the following code:

<p>color</p>
p {
   color: red;
}
p {
   color: blue;
}

same question as before, what color will the paragraph be?

blue, if there is not difference in hierarchy between selectors, the last property is applied.