2

Is it possible to define style for pseudo-elements inside html container? Something like

 <div style=":after{background:red}">

The background image will be defined dynamically so I need to put the style in html.

skyisred
  • 6,855
  • 6
  • 37
  • 54

2 Answers2

1

No. You can't. Style attribute doesn't allow selectors.

Take a look

CSS Pseudo-classes with inline styles

http://www.w3.org/TR/css-style-attr/ (W3C Recommendation)

You can, by the way, use tag <style>...</style> to add on HTML file.

Community
  • 1
  • 1
fntneves
  • 394
  • 2
  • 6
0

Try injecting it through jQuery after generating background.

pseudo-elements should be defined in CSS.