<div class="parent">
<div class="child">
</div></div>
In CSS, "child" class has its own bg color, that I can't change. I want to apply "parent" class bg color to container. So, Is there any CSS trick to override "child" bg color by "parent" bg color.
Any help would be much appreciated.
html worked fine, overrides the external css. Show activity on this post. Either apply the style="padding:0px;" on the content div inline (not recommended), or load your style after you load your external style sheet.
CSS allows you to apply styles to web pages. More importantly, CSS enables you to do this independent of the HTML that makes up each web page. Overriding: Overriding in CSS means that you are providing any style property to an element for which you have already provided a style.
!important will override any inline background color applied, let me know if this works
.parent > .child {
background-color: transparent !important;
}
.parent .child {
background-color: inherit !important; // can also use "transparent"
}
Use !important
only if nothing else works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With