• No ability to connect styles
  • There is no way to insert styles between <style> </style>

<div style="background: #333; padding: 10px;">Dark gray</div>

How to prescribe him a "hover", for example background: #555; right inside style="" ?

3 answers 3

Pseudo-class selectors cannot be described directly in the tag. If there is no possibility to connect styles, use the onmouseover and onmouseout .

 <div style="background: #333; padding: 10px;" onmouseover="this.style.backgroundColor='#555';" onmouseout="this.style.backgroundColor='#333';"> Dark gray </div> 

    No, hover is a pseudo-class.

      And on w3.org it is written that you can: https://www.w3.org/TR/2002/WD-css-style-attr-20020515

      Setting properties for a dynamic states, using pseudo-classes:

        <a href="http://www.w3.org/" style="{color: #900} :link {background: #ff0} :visited {background: #fff} :hover {outline: thin red solid} :active {background: #00f}">...</a> 

      • The given snippet does not work. The answer is in English . In addition, the link in the response is sooo old (2002). Here is newer and there is nothing like that - Grundy
      • the letters WD mean Working Draft, in other words - a draft. The standard of this syntax is not. - Sasha Omelchenko
      • Clear. Very sorry. - Tango