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.
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.
Try injecting it through jQuery after generating background.
pseudo-elements should be defined in CSS.