Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a:visited in inline CSS?

Tags:

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.

like image 522
Atara Avatar asked Feb 06 '12 15:02

Atara


People also ask

What is a visited in CSS?

The :visited CSS pseudo-class represents links that the user has already visited. For privacy reasons, the styles that can be modified using this selector are very limited.

What is an example of inline CSS?

Inline CSS: Inline CSS contains the CSS property in the body section attached with element is known as inline CSS. This kind of style is specified within an HTML tag using the style attribute. Example: html.

How do you inline a CSS file?

CSS can be added to HTML documents in 3 ways: Inline - by using the style attribute inside HTML elements. Internal - by using a <style> element in the <head> section. External - by using a <link> element to link to an external CSS file.

Which is used to set a visited link in HTML code?

Definition and Usage The :visited selector is used to select visited links. Tip: Use the :link selector to style links to unvisited pages, the :hover selector to style links when you mouse over them, and the :active selector to style links when you click on them.


1 Answers

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.

like image 114
kibibu Avatar answered Nov 24 '22 13:11

kibibu