Posted By: Anonymous
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.
Short answer: you can’t.
Long answer: you shouldn’t.
Give it a class name or an id and use stylesheets to apply the style.
:hover is a pseudo-selector and, for CSS, only has meaning within the style sheet. There isn’t any inline-style equivalent (as it isn’t defining the selection criteria).
Response to the OP’s comments:
Also, don’t forget, you can add links to external stylesheets if that’s an option. For example,
Caution: the above assumes there is a head section.