how to override a css inline without affecting the main element

Viewed 30

I know how to override css using !important but what if the HTML is

<p style="font-weight:bold;">hello</p>

I do not want to affect the other P but only P with style="font-weight:bold;"

3 Answers

You can use the style attribute in css as you would with any other attribute.

p[style*="font-weight:bold"] {
    font-weight: bolder;
}

already figured it out using p[style]

You can do this by:

p[style*="font-weight: bold"] {
    /* some styles */
}

You can also use this technique for selecting HTML tags with other attributes like target.

You can look up here for more information on selectors:

Selector Reference

Related