I have a case where I must write inline CSS code, and I want to apply a hover style on an anchor.
How can I use a:hover
in inline CSS inside the HTML style attribute?
E.g. you can't reliably use CSS classes in HTML emails.
I have a case where I must write inline CSS code, and I want to apply a hover style on an anchor.
How can I use a:hover
in inline CSS inside the HTML style attribute?
E.g. you can't reliably use CSS classes in HTML emails.
You can use the pseudo-class
a:hover
in external style sheets only. Therefore I recommend using an external style sheet. The code is:I'm extremely late contributing to this, however I was sad to see no one suggested this, if you actually require inline code, this is possible to do. I needed it for some hover buttons, the method is this:
In this case, the inline code: "background-color: red;" is the switch colour on hover, put the colour you need into there and then this solution works. I realise this may not be the perfect solution in terms of compatibility however this works if it is absolutely needed.