How to write a:visited in inline CSS?

女生的网名这么多〃 提交于 2021-02-18 19:55:02

问题


Related Topic: How to write a:hover in inline CSS?

I need to create an HTML Email News Letters. All styles should be inline. (According to – http://www.campaignmonitor.com/css/ Not all email clients recognize STYLE tag with in the HEAD tag. but they all prefer inline styles.)

My Problem: The designer wants a dark background color + white links, so I use -

<a href="http://www.mySite.com" target="_blank">
  <span style="color: #ffffff;" >ici</span>
</a>

but the default "visited color" is dark.

Is there another way to change the "visited color" ?

Thanks,

Atara.

P.S. I also tried the decrypted BODY link, vlink attributes. did not work.


回答1:


First off, good luck! HTML email is stuck firmly at 1996 tech levels.


One thing to attempt if you don't actually need a separate "visited" colour is to add an !important on the span.

For example, your mail client may have something like this in their style sheet:

a:visited * { color: #000 !important; }

In which case that will override your inline style.

So, try changing your span to:

<a href="http://www.example.com" target="_blank">
    <span style="color: #ffffff !important;" >ici</span>
</a>

to override it back again.

A quick test in Chrome shows that the a:visited * { ... !important} does override the inline style, but adding the !important back to the span works fine.


2017 Update

The CampaignMonitor CSS guide now seems to recommend using a <style> element in the head, rather than inlining all styles. Based on other answers this seems to provide the best compatibility with recent version of Outlook.




回答2:


This is pretty old thread but thought it would be useful to somebody. Nothing else worked for me in outlook 2013 except using the plain old

<style>a:visited{color:white !important}</style>

within the body




回答3:


Why not try setting the style attribute inside the <a> tag and removing the <span> altogether?

Doing that inline should overwrite the :visited property.

Like this:

<a href="http://www.example.com" target="_blank" style="color: #ffffff !important;" >
    ici
</a>

Note: And just to be safe you can add the !important property in there to further back it up.

I think this is the best practice and the cleanest way to do this.




回答4:


I tried all that ideas described here in 2016 (with Outlook 2010 and up), none of them worked for me. But I had success using this solution: https://jamesnorthard.com/outlook-changing-visited-link-color-in-email/

He uses the strong tag inside the anchor tag (code from his blog post): <a href="#" style="color:#333399;"><strong style="font-weight:normal;">My Link</strong></a>

It even fixes the problem of a changing link color when forwarding an email with Gmail.

Hope that helps anyone else!




回答5:


a quick and dirty solution : add vlink = "yourcolor" in the body of your HTML Email News Letter (works with !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd")



来源:https://stackoverflow.com/questions/9162362/how-to-write-avisited-in-inline-css

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!