CSS pseudo-element in inline attribute style

放肆的年华 提交于 2019-11-28 10:57:31

问题


I have tried with the sample below from the url. What I trying is to apply css pseudo-element in inline attribute, style. Somehow, it seems not working. I would appreciate for any advice.

http://www.w3.org/TR/2001/WD-css-style-attr-20010305

    <p style="{color: green; width: 10em} ::first-letter {float: left; font-size: 300%}">

This is an example of a paragraph with inline style attribute rules to create a spot effect, in this case, a drop-cap first letter.

</p>

回答1:


It’s not possible. The working draft you are referring to is over 12 years old. Click on the link “Latest version” in it, and you’ll find the CSS Style Attributes, a W3C Recommendation (“W3C standard”). It was approved recently. It contains no changes to the style attribute as in HTML specs, and this is indeed the message: the attribute has not been enhanced, and there are no plans to do so.

The conclusions depend on why you would use the construct. Normally, just assign an id attribute to the element and use an id selector in CSS.




回答2:


Try to do it this way

<p style="color: green; width: 10em"><span style="float: left; font-size: 300%">L</span>orem Ipsum</p>


来源:https://stackoverflow.com/questions/20138454/css-pseudo-element-in-inline-attribute-style

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!