Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parent affect Child style in common selector using css

Tags:

css

I have the following markup:

<div id="content">
  <div id="contact">
    <p>Testing p selector in child</p>
  </div>
</div>

And these two css files:

default.css [Parent]

#content p {
color: #000000;
font-size: 14px;
font-family: helvetica;
text-align: left;

}

form.css [Child]

#contact p {
background-color: #F2F7FB;
font: 11px Verdana, Geneva, Arial, Helvetica, sans-serif;       
color: #3670A7;   
text-align: left;       
margin-right: 0px;       
padding-right: 0px;

}

Why the:

<p>Testing p selector in child</p>

is getting the parent's style and not the child's one?

like image 652
Somebody Avatar asked May 20 '26 20:05

Somebody


1 Answers

Credit goes to BoltClock'saUnicorn,

from comments: Is your default.css loaded after form.css?

like image 173
Somebody Avatar answered May 23 '26 15:05

Somebody



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!