html – How do I write: hover inside style = ''?


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

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

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


Pseudo-class selectors cannot be declared directly in a tag. Since there is no way to connect styles, use the onmouseover and onmouseout .

<div style="background: #333; padding: 10px;"
   onmouseover="'#555';" onmouseout="'#333';">
      Dark gray
Scroll to Top