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

Certain css elements wont reflect changes without !important tag

My code is driving me insane. I can't make changes to certain things in my external style sheets with out adding !important tag to something. I am also running into the issue that css will understand if i use the ID tag instead of the element when theyre suppose to be the same exact thing. for example

<nav class="navbar navbar-inverse navbar-fixed-top" id='head'>

if i was to try and write:

nav{ background: transparent; margin-top: 15px; border: none; }

nothing would happen. But the moment i change nav to a class name or ID its like magic is happening. I made sure that there isn't anything else overriding the rules and things seem to be clear. HELP.

i guess i should also mention i am using bootstrap and sass.

1 Answer

Kallil Belmonte
Kallil Belmonte
35,561 Points

Hi, certain selectors have more priority than others as you may know, for understanding the priority order take a look at this post:

Reviewing CSS Style Priority Level

There's also a calculator for finding out who 'wins' who as a selector that receives the final style:

Specificity Calculator

You can also search more using the phrase "css specificity"