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 st
So this isn't quite what the user was looking for, but I found this question searching for an answer and came up with something sort of related. I had a bunch of repeating elements that needed a new color/hover for a tab within them. I use handlebars, which is key to my solution, but other templateing languages may also work.
I defined some colors and passed them into the handlebars template for each element. At the top of the template I defined a style tag, and put in my custom class and hover color.
<style type="text/css">
.{{chart.type}}-tab-hover:hover {
background-color: {{chart.chartPrimaryHighlight}} !important;
}
</style>
Then I used the style in the template:
<span class="financial-aid-details-header-text {{chart.type}}-tab-hover">
Payouts
</span>
You may not need the !important
I had to avoid javascript, but could go with server side code.
so I generated an id, created a style block, generated the link with that id. Yes its valid HTML.
a {
text-decoration: none;
color: blue;
}
a:hover {
color: blue;
font-weight: bold;
}
<!-- some code in the interpreter you use, to generate the data-hover id -->
<style>
a[data-hover="rnd-id-123"] { color: green; }
a[data-hover="rnd-id-123"]:hover { color: red; }
</style>
<a data-hover="rnd-id-123">some link 1</a>
<br>
<!-- some code in the interpreter you use, to generate the data-hover id -->
<style>
a[data-hover="rnd-id-456"] { color: purple; }
a[data-hover="rnd-id-456"]:hover { color: orange; }
</style>
<a data-hover="rnd-id-456">some link 2</a>
This is pretty late in the game, but when would you use JavaScript in an HTML Email? For example, at the company I currently work for (rhymes with Abodee), we use the lowest common denominator for most email marketing campaigns – and JavaScript is just not being used. Ever. Unless you are referring to some kind of pre-processing.
As mentioned in a related post: "Lotus Notes, Mozilla Thunderbird, Outlook Express, and Windows Live Mail all seem to support some sort of JavaScript execution. Nothing else does."
Link to the article from which this was taken: [http://en.wikipedia.org/wiki/Comparison_of_e-mail_clients]
Also, how would hovering translate to mobile devices? That's why I like the answer from above:Long answer: you shouldn't.
If anyone has more insights into this subject, please feel free to correct me. Thank you.
It's now possible with Hacss.
You can do id by adding a class but never inline.
<style>.hover_pointer{cursor:pointer;}</style>
<div class="hover_pointer" style="font:bold 12pt Verdana;">Hello World</div>
2 lines but you can re-use the class everywhere.