Modify status: focus from HTML

2

I wanted to modify the :focus status of an HTML element from the HTML tag itself. Let me explain, for example I can define the styles on the label itself:

<div style='background: grey'>
</div>

That in CSS would be equivalent to putting:

div {
   background: grey;
}

The problem is that I do not know how to modify the styles with the attributes :focus or :hover . In CSS I know what would be the following:

div:hover {
    color: white;
}

I'm trying with:

onmouseover="this.style.boxShadow=inset 0 1px 1px #C27279;"

I can not get the new style to show.

    
asked by JetLagFox 28.05.2017 в 22:38
source

1 answer

2

It is not allowed to do hover with CSS inline. However, you can always use Javascript to achieve this through onmouseover and onmouseout .

Example:

div{
   color: red;
}
<div onmouseover='this.style.color="white"' onmouseout='this.style.color="red"'>Esto es un texto</div>
    
answered by 28.05.2017 / 22:53
source