Chris Lemon
Chris Lemon

Reputation: 31

Why is !important not working on my stylesheet?

I'm pretty new to CSS/HTML and I need a little help with styling. So I have a CSS style sheet where I did something like this

p{
    color:black;
}

Then in my HTML, inside of my footer tag, I have a paragraph.

The problem I am having is that I want the color of the paragraph inside of my footer to be blue.

I tried doing something like this:

footer{
    color: blue !important;
}

but it didn't work so I was wondering how I can get just the paragraph in my footer to be blue because I want the rest of my paragraphs to be black.

If the !important method is the wrong approach I was wondering why? From my research, I thought it was supposed to override any previous styling.

Upvotes: 3

Views: 73

Answers (2)

Zeeshan Eqbal
Zeeshan Eqbal

Reputation: 260

Answer:

Why is !important not working on my stylesheet?

It is working perfectly as it is designed.

How I can get just the paragraph in my footer to be blue

For this, please use the appropriate selector.

footer p{
   color: blue;
}

Upvotes: 2

Zunaib Imtiaz
Zunaib Imtiaz

Reputation: 3119

That is a bad practice Try doing something like this For your Footer

HTML

<div class="footer">
<p>This is a paragraph.</p>
</div>

CSS

.footer p {
 color: blue ;
}

Don't use important tags.

Upvotes: 1

Related Questions