views:

47

answers:

5

Recently when coding and HTML email, I noticed that Yahoo! started hijacking certain links and keywords, adding a <span class='yshortcuts'> which changes the colors of the text and links, which can cause some pretty bad rendering problems.

The 'fix' that Yahoo! suggested is pretty ugly (adding a span within all of the links and keywords that are affected) - far from an easy universal solution, especially when they apply the style to seemingly arbitrary text.

I am wondering if it is possible to simply over ride their class, and some how, with css, remove the color attribute. (While <style> blocks aren't supported in all major email platforms, Yahoo! does...and the ones that don't support it, gracefully ignore it.)

Something like <style> .yshortcuts{color:none;} </style>

I know that color:none; isn't valid, and doesn't work universally.

Any Ideas?

A: 

You could try

.yshortcuts { color: auto !important }

I don't know what this will fall back to, though - the browser's default colour, or the next colour definition in the cascade. It will depend on the other CSS rules present.

If that doesn't work, I think you'll have to override it with a defined, new colour.

Unicron
Thanks for the suggestion, I just tried it and it falls back to the color Y! defined for the class. Overriding the `.yshortcuts` with another color, sadly won't quite work since the links are different colors within the email (like in a button, body text, or a linked headline).
Caleb Larsen
@Caleb I see. This is inside the Yahoo mail client so Javascript is not an option, right?
Unicron
Right :(The `color:inherit` works...but not in IE6 (which is a requirement for me)
Caleb Larsen
A: 

You can override color by more specific selector in CSS

body #content .yshortcuts{color:inherit;}
srigi
NICE! That sorta works...IE6 Ignores it tho :( Which, for crazy reasons, I still need to support.
Caleb Larsen
IE6 doesn't support inherit value. There is no way how to restore color. You must specify color explicitly. Or... use something like this: http://code.google.com/p/ie7-js/
srigi
A: 

To work cross browser, you could add some definitions to your css to keep the color your definition. For example, let's say you have this in your css:

p {color: black}
a {color: blue}

Now, I'm not sure if your .yshortcuts is wrapping the a tags or is positioned inside the a tags, but for purposes of my illustration, I'm going to assume they wrap around the a, so a solution would be to change your css to:

p, p .yshortcuts {color: black}
a, .yshortcuts a {color: blue}

Basically, you would have to do this everywhere that color is defined in your css (assuming that Yahoo! could do this to any text). This is not as elegant as the other solutions given, but should work for IE6.

Scott
Yahoo! wraps it like this: `<a href="link.html"><span class=".yshortcuts">My Link</span></a>`
Caleb Larsen
Then my `a` line above would be similar to the `p` line, that is:`a, a .yshortcuts {color: blue}` for my illustration.
Scott
A: 

Unfortunately, I have found that to get reliable styling across most email clients, inline styles are the only way to go. Some strip any styles declared in the head, some add their own classes, some add random extra elements - but by giving every element its own inline style - along with some just wonderful tables - I've gotten it to render consistently in every major client - Gmail, Outlook, Hotmail, Yahoo, etc.

This article is pretty useful for seeing who supports what and where: http://www.campaignmonitor.com/css/

DHuntrods
The problem isn't with initial styling, the problem is correcting the hijacking that Yahoo! is doing. So, everything renders perfectly everywhere, but the "value added" feature that Yahoo! is providing by linking popular phrases...like brand names, phrases like "save now," etc, is what is causing the problem. The hope is to find a simple solution to correct this 'feature' without having to manually modify each link/phrase.
Caleb Larsen
Okay...did "!important" do anything for you?
DHuntrods
Nope, since IE 6/7 doesn't support the `inherit` property, I think we are SOL on finding a slick solution.
Caleb Larsen
A: 

After digging and slogging it seems this is the best way to handle the problem (to my mind).

1) At top of the email, add this style block. This will fix most of the problems in most browsers.

<style> .yshortcuts{color:inherit;} </style>

2) Since we want IE people to be happy too, insert a span, with a color style, inside each <a> that is causing problems. E.g.:

<a href="http://google.com" style="#c912dc"><span style="#c912dc">Google</span></a>

This should, fix it in almost all situations.

Since this can be a pain to do by hand if you have a file already coded, you can do a regex find/replace and it should help speed things up (but your mileage may vary...works in Textmate):

Find: (<a[^>]*style=".*color:#(\w{6}).*".*>)(.+)(</a>)

Replace: $1<span style="color:#$2;">$3</span>$4

Caleb Larsen