Search code examples
htmlcsscss-selectorsinline-styles

CSS selector for element within element with inline style?


Is there a CSS selector to target elements with inline styles? So can I target the first span but not the 2nd with CSS only?

If not, can this be done with jQuery?

http://jsfiddle.net/TYCNE/

<p style="text-align: center;">
    <span>target</span>
</p>

<p>
    <span>not target</span>
</p>
​

Solution

  • p[style="text-align: center;"] {
      color: red;
    }
    

    However this is ugly.