tags:

views:

91

answers:

1

I'm having problems linking a second stylesheet to my HTML document, and cannot find the (hopefully painfully obvious) problem.

I'm linking stylesheets in the head thus:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd"&gt;
<html>
<head>
<link rel="stylesheet" href="assets/css/global.css" type="text/css" media="all" title="Global styles" charset="utf-8">
<link rel="stylesheet" href="assets/css/ie.css" type="text/css" media="all" title="IE Overrides" charset="utf-8">

The problem is, the seconds stylesheet has no effect what so ever. Reversing their order proves this as well.

For testing, I put in a rule in the second stylesheet to make the body background red, even tried adding !important, but to no avail.

/* Global CSS */
body {
    background-color: #fff;
}

/* IE CSS */
body {
    background-color: #f00 !important;
}

Firebug net panel shows that both stylesheets do load, and the style panel shows me the styles in both of them, but the rules in the latter just don't do squat.

This has left me baffled, since it is very, very basic stuff, which I've previously done successfully hundreds and hundreds of times.

+4  A: 

Try removing the title attribute from both your link tags. title has a special meaning when used with stylesheet links, more here:

Alternative Style: Working With Alternate Style Sheets

Pekka
A thousand thanks to you, sir!
nikc
You're welcome! This "feature" is totally weird and counter-intuitive and should be abolished IMO. This is impossible to know if you haven't stumbled upon it in the past.
Pekka
Indeed. I've, in fact, never before utilized the `title`-attribute on `link`-tag before (slap forehead), but did now, since my new and shiny editor, E, autofilled it when using `link<tab>` autocompletion, and I foolishly assumed it wouldn't actually do anything, but just look nice and shiny.
nikc
+1 for your answer, always useful
c0mrade