Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use CSS hover inside html-tag? [duplicate]

Tags:

html

css

I want to do something like this:

<li style="hover:background-color:#006db9;">

But it wont work. Is this possible to do in some way, or do I have to write the css in the head or external css-document?

like image 248
Johan Avatar asked Dec 02 '09 17:12

Johan


1 Answers

It is not possible with inline styles, but the (in)famous onmouseover / onmouseout event handler can do the same thing.

<li onmouseover="this.style.backgroundColor='#006db9'" onmouseout="this.style.backgroundColor=''">

Caveat: CSS definitions with hyphens have to be translated to Javascript using camelCase, like (css)background-color = (javascript)backgroundColor

like image 59
Residuum Avatar answered Sep 28 '22 03:09

Residuum