-2

If the priority of the id selector in css is the highest, why are the background colors of the two p's (test1 and test2) are same blue?

enter image description here

I have tried to change the order of selectors in the style code block and ways to express the id selector. like p #123 {} and #123 p {} .

I want to know the principle and how to use the id selector correctly in this case. Thank you very much.

mplungjan
  • 169,008
  • 28
  • 173
  • 236
red5pin
  • 1
  • 2

3 Answers3

-2

Your mistake is naming id. You must name id without numbers (change it to some word i.e test) and it works.

enter image description here

mplungjan
  • 169,008
  • 28
  • 173
  • 236
-2

Change the id to letters (or let it start with a letter) The first character of id cannot be a number

Itzik
  • 275
  • 2
  • 4
-3

ID will be selected before the Tag "#example" will have priority in front of "button tag"