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.
I just figured out a different solution.
My issue: I have an
<a>
tag around some slides/main content viewer as well as<a>
tags in the footer. I want them to go to the same place in IE, so the whole paragraph would be underlinedonHover
, even though they're not links: the slide as a whole is a link. IE doesn't know the difference. I also have some actual links in my footer that do need the underline and color changeonHover
. I thought I would have to put styles inline with the footer tags to make the color change, but advice from above suggests that this is impossible.Solution: I gave the footer links two different classes, and my problem was solved. I was able to have the
onHover
color change in one class, have the slidesonHover
have no color change/underline, and still able to have the external HREFS in the footer and the slides at the same time!There is no way to do this. Your options are to use a JavaScript or a CSS block.
Maybe there is some JavaScript library that will convert a proprietary style attribute to a style block. But then the code will not be standard-compliant.
My problem was that I'm building a website which uses a lot of image-icons that have to be swapped by a different image on hover (e.g. blue-ish images turn red-ish on hover). I produced the following solution for this:
I introduced a container containing the pair of images. The first is visible and the other is hidden (display:none). When hovering the container, the first becomes hidden (display:none) and the second shows up again (display:block).
This is the best code example:
Hover is a pseudo class, and thus cannot be applied with a style attribute. It is part of the selector.
You can do id by adding a class but never inline.
2 lines but you can re-use the class everywhere.