Override element.style using CSS
Although it's often frowned upon, you can technically use:
display: inline !important;
It generally isn't good practice but in some cases might be necessary. What you should do is edit your code so that you aren't applying a style to the <li>
elements in the first place.
How do you determine what is overriding your style?
In devtools, in the style inspector, choose Computed. Find the property you are interested in and click it. You will see a list of all the rules that apply to this property, with the active one at the top, and each with a file/line reference to where it is defined.
Consider the following HTML:
<style>
#foo { color: red; }
p { color: blue; }
</style>
<p id="foo">What color am I?</p>
You would see the following:
Why does element style override class that is set on element?
Both rules have the same specificity, so whichever rule comes last in the style declarations will win... Are you sure that the .parent a
-rule is specified after the .content a
-rule?
Another way to solve it would be to increase the specificity slightly, i.e:
.parent .child_item {
font-size: 16px;
}
Edit: You can play around with your test case here: http://jsfiddle.net/gburw/
To prove my point, try switching the CSS-declarations and you will see that whichever rule is defined last will "win".
Edit 2: You can read more about CSS specificity here. It's a pretty simple concept to grasp, the hard part is avoiding specificity wars with fellow developers =) So you should come up with a standard way you write CSS in your company. Following the guidelines of Pagespeed and YSlow is also always a good idea.
Related Topics
Create Angular Material Theme with CSS Variables
What Is the Third Value in CSS Padding
CSS Font-Face with the Arabic Fonts
Evenly-Spaced Navigation Links That Take Up Entire Width of Ul in CSS3
Javafx CSS Button with Image - How to Define the Size of the Image
Create a W3C Validated Anchor Link with Target="_Blank"
Setting an Input Box Background
Svg Symbols Not Being Displayed in Firefox
Safari Rounding Down on Subpixel Calculations
Adding CSS Stylesheet to Pages Based on Route in Opencart
How to Set Multiple CSS Style Properties in Typescript for an Element
Is There a Clean Way to Get Borders on a <Tbody /> in Pure CSS
How to Make Placeholder and Label Transitions
CSS - "Position: Fixed" Acting Like "Absolute" in Firefox
What Is the Different Between :Host ,:Host() ,:Host-Context Selectors