Andre Smith
Andre Smith

Reputation: 207

My .css file does not work on my webpage

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>

Upvotes: 0

Views: 1593

Answers (5)

Bogdan Rybak
Bogdan Rybak

Reputation: 2117

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

Upvotes: 2

Rashed
Rashed

Reputation: 35

just remove the style tag and it will work

Upvotes: -1

Austin
Austin

Reputation: 170

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>

Upvotes: 1

David Taiaroa
David Taiaroa

Reputation: 25495

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!

Upvotes: 1

adaam
adaam

Reputation: 3706

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.

Upvotes: 2

Related Questions