inline-styles in the document have the highest priority, for example, say you want to change the color of the div element to blue , but you have an inline style with the color property set to red
<div style="font-size: 18px; color: red;"> Hello World, How Can I Change The Color To Blue? </div>
div { color: blue; }
So, should jQuery / Javascript be used? - No answer
We can use element-attr CSS Selector with !important , note that !important is !important here, otherwise it will not move the inline styles.
<div style="font-size: 30px; color: red;"> This is a test to see whether the inline styles can be over ridden with CSS? </div>
div[style] { font-size: 12px !important; color: blue !important; }
Demo
Note. Using !important will ONLY work here, but I used div[style] to select a div having a style Attribute
Mr. Alien May 29 '13 at 11:56 2013-05-29 11:56
source share