Reputation: 81711
Note : Solution has been appended to the answer at the bottom.
Okay, I've been doing it all the time but now it doesn't work.
Here is my folder structure which is so simple :
+ root |_ + styles |_ -main.css |_ + images |_ - background.jpg |_ - index.html
Here is the html code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<link href="styles/main.css" type="text/css"/>
</head>
<body>
<div class="main">
</div>
</body>
</html>
Css Code :
body
{
}
div .main
{
background-image:url(../images/main_background.jpg);
background-repeat:no-repeat;
height:950px;
width:897px;
}
The problem is : css file doesn't seem to be loaded and there is no css styles applied to class name main
on the html file. That's really frustrating. I've also put them under IIS creating an Application under.
What could be wrong?
Thanks.
Solution:
Since the both answer should be at the same place to solve my problem, I decided to put complete answer here:
div.main
<link href="styles/main.css" type="text/css" rel="stylesheet"/>
Upvotes: 1
Views: 567
Reputation: 7550
I think div .main
in the css should read div.main
. Note the lack of space.
With the space you are specifying child elements of divs, where the child has class main, without the space you are specifying divs with the class main.
Upvotes: 2
Reputation: 2928
You need to declare the rel
attribute for the link
for your CSS file, like so:
<link href="styles/main.css" type="text/css" rel="stylesheet" />
Upvotes: 2
Reputation: 18964
Change the path from relative to absolute:
<link href="styles/main.css" type="text/css"/><!-- relative -->
<link href="/styles/main.css" type="text/css"/><!-- absolute -->
Upvotes: 0