[thelist] inline css

Mark Henderson morgoth at ispnz.co.nz
Fri Mar 16 01:35:34 CDT 2007

Casey Crookston wrote:
> Yes, I know.  Inline css is a bad idea.   I understand.  But in this
> case, it cant be avoided.... I'll spare you the details.  According to
> W3.org, this should work:
> <a href="page.html" style="{font-size: 12px; text-decoration:none;
> color: #006633;} :hover {color: black;}">link</a>

I don't think so. Unless my email program is munging your text, those 
inline styles should look more like this:

<a href="page.html" style="font-size:12px; text-decoration:none; 

...with no curly brackets embedded.

> The first part works: {font-size: 12px; text-decoration:none; color:
> #006633} but the hover doesn't.  Not sure why.  Again, I don't like
> doing this inline either, but it has to be this way this time.

AFIK, with inline styles you can only style the link itself, because 
that's what the style is on (so pseudo-elements are out). You could try 
something like the following:

<a href="page.html" onmouseover="this.style.color='red'">Test</a>

...but that's pretty ugly too. Alternatively, place the relevant styles 
in a <style> block either in the head (or just after the body if this is 
for html email). Without more information that's all I can suggest.


More information about the thelist mailing list