What's Default HTML/CSS Link Color

What's default HTML/CSS link color?

As of HTML5, the foreground colors of hyperlinks, among other things, are on track for standardization in the form of guidelines for expected default rendering behavior. In particular, taken from the section Phrasing content, the recommended default colors for unvisited and visited hyperlinks are the following:

:link { color: #0000EE; }
:visited { color: #551A8B; }

Notice that there is no recommended default for active hyperlinks (:link:active, :visited:active), however.

You can use these default colors and reasonably expect them to work. But keep in mind that a browser is free to ignore any or all of these guidelines, as it is never required to follow them. It is, however, recommended for a consistent user experience across browsers (which is how "expected" is defined in this context), so chances are that these colors will correspond to the defaults for most browsers. At worst, they still serve as reasonable approximations of the actual values.

In particular, the default unvisited and visited link colors in the latest versions of Firefox and Chrome are consistent with the above guidelines, but recent versions of IE report different values: unvisited links are rgb(0, 102, 204), or #0066CC, and visited links are rgb(128, 0, 128), or #800080. Older versions of Firefox (and possibly Safari/Chrome) had different defaults as well. Those are older versions, however; the main outlier today that I am aware of is IE. No word yet on whether this will change in Project Spartan — currently it still reflects the same values as the latest version of IE.

If you are looking for a standardized color scheme that is used by all browsers rather than suggested by HTML5, then there isn't one. Neither is there a way to revert to a browser's default value for a particular property on a particular element using pure CSS. You will have to either use the colors suggested by HTML5, or devise your own color scheme and use that instead. Either of these options will take precedence over a browser's defaults, regardless of browser.

If in doubt, you can always use the about:blank technique I described before to sniff out the default colors, as it remains applicable today. You can use this to sniff the active link color in all browsers, for example; in the latest version of Firefox (29 as of this update), it's rgb(238, 0, 0), or #EE0000.

How do I remove the default link color of the html hyperlink 'a' tag?

The inherit value:

a { color: inherit; } 

… will cause the element to take on the colour of its parent (which is what I think you are looking for).

A live demo follows:

a {
color: inherit;
}
<p>The default color of the html element is black. The default colour of the body and of a paragraph is inherited. This
<a href="http://example.com">link</a> would normally take on the default link or visited color, but has been styled to inherit the color from the paragraph.</p>

HTML default link color

Even if you don't change the default color, it would still be a good idea to specify the color to ensure that it looks the same in all browsers. I'd put something like this in the stylesheet:

a, span.link {
color: blue;
}

a:visited, span.visited {
color: purple;
}

a:active, span.active {
color: red;
}

Then you can style spans as links by <span class="link">Your fake link</span>

Default color from link won't change

You need to apply this style to the <a> tag, not the <span>. But more importantly, you're using the same id of links twice, which is not legal. Change it to a class instead:

<p>Viens voir toute la team NoMaD en action! Disponible sur <span id="links"><a href="https://www.youtube.com/channel/UCx9wXRznZvavCSXkbrJoDYw?view_as=subscriber">YouTube</a></span>, <span class="links"><a href="https://www.twitch.tv/teamn0mad">Twitch</a></span>, et  <span class="links"><a href="https://www.instagram.com/la_team_nomad">Insta</a></span>.</p>

Then change your CSS to select on this class instead of the id:

.links a {
color:inherit;
text-decoration:none;
transition:color 1s;
}

.links a:hover {
color:white;
}

How can I change link color in html email?

Thanks to mplungjan I realised that my solutions were wrong and it's an easy fix.
Thank you for everyone who posted solutions!

<a href="www.xyz.com" style="text-decoration: none; color: #959595; cursor: pointer">www.xyz.com</a>

CSS a:link keep original color

Try this in your stylesheet:

a:link {
color:inherit;
}

Note that you then probably should make sure you have some other way to identify links, or your users will be confused. (I.e. don't remove the underlining, too.)

If you want to deal with browsers not supporting inherit, I suppose repeating the definition which originally set your color will do.

As an example, assume the class important should be shown in red:

.important {
color:red;
}

.important a:link {
color:red;
}

But of course it is not nice to have to double all color indications. I assume one could do something in JavaScript (looping through all the a elements and giving them the right class explicitly). (I have no IE available to test this.)

Is there a way to unset an 'a' tag link to the default color

The value for original setting you're looking for is called initial.

a:hover {
color: initial
}

However, that might make the link black. Which means it wouldn't work for you in this case. You can get around this another way though, through your a style. Use the inverse of :hover using the :not selector.

a:not(:hover){
color: #000;
text-decoration: none;
}
<a href="#">Hi, I'm Link.</a>

Reset link colour to browser default

Edit:

Another way is avoiding the problem from the beginning. Give the special links you want to be with the default style a special class (let's call it .default), and instead of:

a:link    { color: black; }
a:visited { color: black; }

Use the not pseudo class and write:

a:not(.default):link    { color: black; }
a:not(.default):visited { color: black; }

Notice that this pseudo class doesn't work on IE 8 and lower. For them you can use a special CSS (I don't like it, but it'll work).



Related Topics



Leave a reply



Submit