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


Change Background Color of Panel-Heading (Bootstrap)

Hey guys, For my own project I am trying to customize bootstrap but when I try to change the background color of the panel heading component nothing changes.

I use this code:

.panel-heading { background-color: red; }

3 Answers

Hi Jacob,

bootstrap.css contains a few style rules like this:

.panel-default > .panel-heading {
  color: #333;
  background-color: #f5f5f5;
  border-color: #ddd;

This is one of the style rules that sets the background on "panel-heading". There are a few more like this depending on the type of panel you nested your panel-heading in.

The selector that you tried to use, .panel-heading, doesn't have enough specificity to override that.

If you simply match the selector that bootstrap uses then you'll be able to override that css.

Assuming that you nested your .panel-heading in a .panel-default then this should work:

.panel-default > .panel-heading {
  background-color: red;

I can give a more specific answer if you want to show the html that you're using for this .panel-heading, specifically what is it nested inside.

try to put your code in the end of bootstrap css file and adding !important in your css selector.

.panel-heading {background-color: red!important}

hope that's work.

Hi Donny,

I think that !important should be used sparingly if at all.

If you do this then you won't be able to override this style later on in a media query for example. You're pretty much stuck with red now.

Thanks that worked! I actually wasn't aware that I could add !important, that made it work in my css file