Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Hector Domingo

macrumors newbie
Original poster
May 2, 2009
26
0
Hi all,
can you please take a look at my HTML file where i've tried to use an external css file - the problem is: it just doesn't seem to recognise it :(

index.html ~

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>

<title>Patrick Rice</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="HAPedit 3.1">
<link href="Style.css" rel="stylesheet" type="text/css">

</head>
<body>
<div id="container">
<p>
</p>
</div>


</body>
</html>


Style.css ~
body {
color:#ff0000;
text-align:center;
}

#container {
color:#0000ff;
width:900px;
}

Please can you tell me why it's not working,
Thanks
 
How do you know it's not working? That html document has no content.

The stylesheet you posted only has text color declarations, so without any text on the page you won't know whether it's working or not.

And like miles said, make sure the path to the CSS file is correct.
 
Just a tip: Your meta and link tags are self closing so they should end like this />. There should also be a space after the last character and the close.
 
Just a tip: Your meta and link tags are self closing so they should end like this />. There should also be a space after the last character and the close.

Naw. Them's XHTML rules. The DOCTYPE clearly defines HTML. No self closing tags.

And the space before the close is completely optional and a stylistic choice.
 
bootedbear, you're right about that being necessary for xhtml only. However, iirc, the space before the close is helpful for certain browsers (take a guess) which are easily confused by valid syntax.
 
I might be stating the obvious, but if the files are hosted on a case-sensitive operating system make sure your CSS file is really called Style.css and not style.css or STYLE.CSS, etc.
 
OP: You should keep your files names in lowercase; Style.css should be style.css. It is not compulsory but just good coding practice.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.