...

View Full Version : Am I linking my css wrong?



mwmnj
08-03-2010, 05:11 PM
Hello all,

I am completely new to web development and am trying to learn by building my own website. The issue I have run into is getting my css to work on my page.

HTML:
<html>

<head>
<LINK rel="stylesheet" type="text/css" href="style.css">
<title> The Shore Report </title>
</head>

<body>

<img src="TheShoreReport.jpg" >

<img src="Web Background.jpg" >


</body>

</html>

CSS:
body
{
background-color:#b0c4de;
}

Is there something wrong with my link or what?

byuhobbes85
08-03-2010, 06:20 PM
Try this.



<link rel="stylesheet" type="text/css" href="style.css" />


Any tags that do not have an open and a closing tag need to be self-closed like the one above. You also need to make sure that your HTML file and your CSS file are in the same directory.

mwmnj
08-03-2010, 06:25 PM
hmm,nope

byuhobbes85
08-03-2010, 06:36 PM
hmm,nope

And what exactly do you mean by "hmm,nope"? What is the issue? I tested the code above (with the modification I suggested) and I see the background color the CSS specified. What are you expecting to see that you don't see?

tjoyce0909
08-03-2010, 06:42 PM
or you have your stylesheet outside of the root of the html document. We can't know for sure without knowing what directory the css file is in.

skywalker2208
08-03-2010, 06:55 PM
Do you have a link to a live site?

mwmnj
08-03-2010, 07:02 PM
The code looks perfect so i suspect it is either an issue with the way i am trying to view my site or the locations of my html/css files.

The way I am viewing my html file is just by clicking the firefox document it saves as and viewing it in firefox.

Both .css and .html files are in the same folder on my desktop.

The background color is white when css is supposed to make it a blue.

skywalker2208
08-03-2010, 07:05 PM
If you don't have a link can you attach both files?

mwmnj
08-03-2010, 07:10 PM
My computer saves .html files as firefox documents automatically and it doesn't seem like I can upload it through here.

here is the text contained inside of my html file though:

<html>

<head>
<LINK rel="stylesheet" type="text/css" href="style.css" />
<title> The Shore Report </title>
</head>

<body>



</body>

</html>

skywalker2208
08-03-2010, 07:15 PM
Is the style sheet you uploaded the exact name of the file or did you add the .txt file extension? If you didn't add the .txt extension then remove it.


If I use your style sheet without the .txt extension it works for me.

mwmnj
08-03-2010, 07:19 PM
Ah, that might be it. How do i remove the .txt? I am trying to resave the .css file with all files instead of .txt but it defaults to .css.txt even when doing that.

tjoyce0909
08-03-2010, 07:58 PM
You are probably on a windows machine that is omitting the true extension name. follow these instructions to show the file extensions then just right click and hit rename and delete the .txt

http://www.fileinfo.com/help/windows-show-extensions.html

mwmnj
08-03-2010, 08:09 PM
That did the trick. thanks a lot everyone. what a dumb issue



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum