Jump to content

Html and css will not link


nevermore

Recommended Posts

I have found a few topics on here similar to my problem, but none of them helped me.

 

I am using a program called gedit to do my coding and viewing it in the browser. I can't seem to get the css and html pages to connect, they are in the same folder, but the changes I make in the css aren't showing up when I refresh the browser. Here is my coding for both.

 

Html page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-…
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="shortcut icon" href="/favicon.ico">
</head>
<body>
<div id="header_wrap">
<div id="header">
<div id="site_logo">
</div>
</div>
</div>
<div id="menu_wrap">
<div id="menu">
<ul>
<li>Home</li>
<li>About</li>
<li>Stories</li>
<li>Art</li>
<li>Forum</li>
<li>Chat</li>
<li>Tutorials</li>
</ul>
</div>
</div>
</body>
</html>

style.css:

body {
background:#2b1b17;
}

#header_wrap{

}
#header{

}

#site_logo{

}

#menu_wrap{

}

#menu{


}
#menu ul{

}

#menu li {

}

 

I am following the 1stoptutorials css on youtube I am on lesson 6.I also checked the file the guy used and they came up blank with detail it was just the text. I have looked at this tut on a windows computer ( I use linux now) and it worked fine. And yes the css file is name style.

Link to comment
Share on other sites

The coding looks correct provided both files are in the same folder. Make sure that there are no lower case/upper case differences.

 

Style.css is not the same as style.css

 

Check your file list and make sure that the css file has been saved as style.css and not as style.css.txt as sometimes the .txt is added automatically when it shouldn't be.

 

At the moment all you should see is the background color as the other styles have no code.

Link to comment
Share on other sites

And once you get your CSS linked and begin styling the other parts - be sure to put some content into those divisions first, so you can actually see them. By default, a division is as big as its content, and if there is none, you see nothing. That's why Lorem Ipsem was invented.

Link to comment
Share on other sites

I'm not super familiar with Linux, but since this has been a problem for some beginners on Windows and Mac... I would double check that your css file is named correctly, and isn't actually named "style.css.txt". Windows and Mac both hide the file extension by default (I'm not sure about Linux), so I would look at this just in case.

Link to comment
Share on other sites

If you're absolutely sure the file names are correct, then if you're testing with Internet Explorer make sure to empty the cache as it caches your CSS and Javascript files, or if you're using Firefox then CTRL+F5 should do the trick.

 

It's easy to check if the file name is correct. Just visit the CSS file with your browser, instead of index.html put style.css and see if that opens or returns 404 Not Found error. If it returns 404 then try opening style.css.txt

Edited by BeeDev
Link to comment
Share on other sites

grrr....this is annoying. They are both in the same place

 

file:///home/*****/Desktop/main%20/style.css

file:///home/*****/Desktop/main%20/index.html

 

I tried viewing the site in chrome and I am getting the same problem and I did ctrl+F5 in mozilla, nada.

 

This is what I am getting. It should have a gunmetal color background

 

image.jpg

Link to comment
Share on other sites

This probably doesn't affect the issue, but it's something you'll want to watch out for. See:

file:///home/*****/Desktop/main%20/style.css
file:///home/*****/Desktop/main%20/index.html

and note the '%20' in there? That means there is a space- and a space at the end of a word is invisible and can cause problems. So make sure that your folder is called 'main' and not 'main '.

 

I have taken the code you provided earlier, html and css, and uploaded them here - and as you can see - it works. The reason you only see a black page is that you have defined the black (dark) background color, but no new font color, so the default (black) is displayed - and black on black is awfully hard to see. (If you 'highlight' your screen with your cursor, you'll see the text appear)

 

So we have determined that nothing is wrong with your code. And you say both the css and the html file are in the same folder. Have you checked into the hidden extension issue and made sure your css isn't actually called style.css.txt?

Link to comment
Share on other sites

the text color is going to change later. And I don't see the black at all, it is the default white of the browser I see. I took the space out of main, but there was no change and style.css is defiantly style.css and not style.css.txt . You said it worked for you, so could it be something with my computer? I have coded other pages on this computer before and it worked fine for me and they still work fine. This is the first time this has ever happened. It is quite annoying considering linux doesn't offer a program (that I am aware of) like dreamwaever where you can view the code along side the design. I need it to work in the browser in order to see all the detail i am putting in. Maybe I should just put the style inside the html and work with it that way, instead of trying to link them? Since it doesn't want to work for me.

 

Edit: I just uploaded them to my server and they are not working there either.....

Edited by nevermore
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...