CSS CSS Basics (2014) Basic Selectors Reusing Classes

does ID still have higher priority if its in external css file whilst CLASS is written in internal file?

i get id overides class, and also know that inline>internal>external also. so does it make a difference if ID in external and class in internal (i cant imagine class being able to be use in inline or can you?) or will ID always win? thanks

1 Answer

John Lack-Wilson
John Lack-Wilson
8,165 Points

Good question - I'd recommend seeing for yourself.

  • Write a simple HTML document called index.html and add a div into the body.
  • Add an ID of "test" to the div.
  • Add some text into the div.
  • Add a background of red to an external stylesheet and include this in the HTML
  • Add a background of blue to the head of the document and see which has priority
  • Add a background of green to the inline element
  • See which takes priority