Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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,181 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