Forum Moderators: not2easy
@charset "utf-8";
body {
font: 12px Arial, Helvetica, sans-serif;
background: #6f448a;
margin: 0;
padding: 0;
text-align: center;
color: #333333;
}
body a {
color: #e11d17;
text-decoration: none;
font-weight: normal;
}
body a:hover{
color: #FFFFFF;
background: #e11d17;
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
With the above code my links render as red(good) but my page background color defaults to white(instead of purple). This is driving me nutty, any ideas?
The reason I am making this presumption is that the charset at-rule is invalid if *embedded* along with selectors, in the document. As 4.4 mentions [w3.org], "When a style sheet is embedded in another document, such as in the STYLE element or "style" attribute of HTML, the style sheet shares the character encoding of the whole document." To reiterate, the charset at-rule must not be placed along with any other embedded styles.
There is in fact a Webkit bug ticket [bugs.webkit.org] which relates to this issue, however, please note that there are no specific error parsing rules related to the incorrect placement of the charset at-rule.
b {} between the @charset line and the initial body rule, does that change things? Is the @charset on the very first line of the CSS file? If not, and you place it at the very top before any other content (including white-space), does that help?
See here for charset bug in Safari: [w3.org...]
[edited by: encyclo at 12:40 am (utc) on June 30, 2009]
would you mind explaining what just happened?
No idea ;) But if the CSS validates but the browser is ignoring the first rule, I simply tried making it the second rule instead :)
The empty rule now being ignored is *not* a long-term solution, if the charset bug above is not the culprit, you need to keep looking.
[edited by: encyclo at 12:45 am (utc) on June 30, 2009]