0

Here is my.css code:

body {background-color:black;}
div.heading {text-align: center; background-color:white;border: 10px ridge grey;     margin-top:0px; font-size: 30px; font-family: Arial, Halvetica, sans-serif; color:black;}

The .css files name is Assignment 3.css

Here is my webpages code. The background is white, and the division is not displayed. If I make the style sheet internal then the code works, but as soon as i put the code in a separate notepad file it does not. Here is the code:

<!DOCTYPE html>

<html>

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

<body>
<div class = "heading">
WELCOME TO BUILD A SQUARE
</div>
</body>

</html>
6
  • 2
    do not include spaces. choose something like "global.css" or "main.css". That is most probably your problem. Also, your link rel is inside <style> tags - move it out of it Commented May 26, 2013 at 19:22
  • I just tried linking test file.css and it worked, so its not the problem. @AndreSmith what is your directory structure? Commented May 26, 2013 at 19:24
  • Why does it work when i move it outside? because we were taught to always put the link rel inside style tags> Commented May 26, 2013 at 19:25
  • 3
    I guess your teacher needs to read a book on CSS. link should not be inside style EDIT: style tag acts like a substitute for external css file. You can write whatever's inside your *.css file inside style tag and then you dont have to link anything Commented May 26, 2013 at 19:25
  • it was my bad. not his! but thank you was helpful it sorted my problem out! Commented May 26, 2013 at 19:28

5 Answers 5

2

It should look like this:

<html>
<head>
<link rel="stylesheet" type="text/css" href="yourfilename.css">
</head>
<body>
<div class="heading">
WELCOME TO BUILD A SQUARE
</div>
</body>
</html>

Style declarations such as <link rel..> need to be inside your <head> and as i mentioned before you shouldn't include spaces.

Sign up to request clarification or add additional context in comments.

Comments

2

Spaces are not valid URL characters. Either change your filename to assignment3.css or encode the space Assignment%203.css

Also move <link> out of <style></style>. That's invalid

Comments

1

First thing to check is your file name, because the space may well cause a problem.

Try:

  • renaming your css file to assignment-3.css

  • update the link in the head of your page to
    <link rel = "stylesheet" type = "text/css" href = "assignment-3.css">

If that still doesn't work, check that the css file exists at
www.your-domain.com/assignment-3.css

Good luck!

Comments

1

I think the problem is you put the link inside style tags. Try it inside the head.

<html>
    <head>
        <link rel="stylesheet" type="text/css" href="css.css" />
    </head>
    <body>

    </body>
</html>

Comments

-1

just remove the style tag and it will work

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.