Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome user agent stylesheet overwriting my site style

Tags:

I have the following CSS that styles the link on one of my pages:

a:link, a:visited, a:active {     color: white;     text-decoration: none;     font-weight: bold; } 

However, when I load it, they appear blue in Chrome and white in Firefox. The Chrome dev tools reveal that my style supposedly overwrites the user agent stylesheet:

enter image description here

Why is it not showing correctly? I tried setting the charset at the top of my stylesheet:

@charset "UTF-8";  html, body {     width: 100%;     height: 100%;     margin: 0;     font: 11px "Lucida Grande", Arial, Sans-serif; }  a:link, a:visited, a:active {     color: white;     text-decoration: none;     font-weight: bold; }  input[type=email], input[type=password] {     display: block;     -moz-border-radius: 4px;     -webkit-border-radius: 4px;     border: 1px solid #ACE;     font-size: 13px;     margin: 0 0 5px;     padding: 5px;     width: 203px; } 

But it didn't help. My stylesheet is linked in the head with:

<link href="/assets/global.css?body=1" media="screen" rel="stylesheet" type="text/css"> 

And the html code for the links:

<a href="/users/sign_in">Sign in</a> <a href="/users/password/new">Forgot your password?</a> <a href="/users/auth/facebook">Sign in with Facebook</a> 

This is what they look like in Chrome (13.0.782) - incorrect:

enter image description here

This is what they look like in Firefox - correct:

enter image description here

It looks like the user agent stylesheet is overwriting my style. Why?

like image 257
TK Gospodinov Avatar asked Sep 19 '11 04:09

TK Gospodinov


People also ask

Can you override user agent stylesheet?

You can override user agent stylesheet declarations with your author styles. And indeed, you do that every day when you write your CSS. Author styles override user styles, which override user agent styles.


1 Answers

I don't know why but I add this <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> before <html> and it solved

like image 182
Ahmad Muzakki Avatar answered Oct 14 '22 23:10

Ahmad Muzakki