...

View Full Version : Trying to set my background to black and the text to white.



9adam4
11-21-2012, 12:35 PM
What is wrong with my code?

HTML:

<html>
<div id="head">
<head>MY NAME IS __________
<link rel="stylesheet" type="text/css" href="Stylesheet.css" />
<title>A millionares diary!</title>
</head>
</div>


<div id="h1">
<h1>A MILLIONARE'S DIARY</h1>
</div>

<div id="body">
<body>
</body>
</div>
<ul id="nav">
<li><a href="home.php">Home</a></li>
<li><a href="aboutme.php">About Me</a></li>
<li><a href="cars.php">My Cars</a></li>
<li><a href="blog.php">My Blog</a></li>
<li><a href="feedback.php">Feedback</a></li>
</ul>


</div>
<div id="p">
<p>Hello there, I am a millionare who brags about my journey on the internet
so people like you can sit there are marvel at my glory. Feel free to click on any
of the links below as they will take you to all of the pages you'll need to
appreciate how amazing I am:</p>
</div>

</html>








CSS:

#p{font-family: "Trebuchet MS", arial, sans-serif;
color: white;
background-color:black;
}

#body{
background-color:black;
}

#nav{
width: 100%;
float: left;
margin: 0 0 3em 0;
list-style: none;
display:inline;
a:link {color: yellow; background: black}
a:visited {color: white; background: black}
a:active {color: red; background: black}
}

#nav li{
float: left;
padding-left: 75px;
}
h1 {font-size 40pt;
font-weight: heavy;
letter-spacing: 4px;
font-style: italic;
text-align: center;
color: white;
background-color:black;

}

div.mainheading {height:100px; background-color: black;)





Thanks and I hope you can help me :)

niralsoni
11-21-2012, 04:37 PM
body is a keyword. Dont use is for id. change it and see.

Excavator
11-21-2012, 04:59 PM
Hello 9adam4,
Your document is not laid out properly, the body is what contains your markup and you close it too soon.

While giving your elements id's like body, h1 and p is not invalid a more descriptive naming convention might help you.

You have other errors as well. See the links about validation in my signature line. Validating is an easy way to catch errors like these.

Look at a valid example of your markup -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="Stylesheet.css" />
<title>A millionares diary!</title>
</head>
<body>
<div id="h1">
<h1>A MILLIONARE'S DIARY</h1>
</div>
<div id="body">
<ul id="nav">
<li><a href="home.php">Home</a></li>
<li><a href="aboutme.php">About Me</a></li>
<li><a href="cars.php">My Cars</a></li>
<li><a href="blog.php">My Blog</a></li>
<li><a href="feedback.php">Feedback</a></li>
</ul>
<div id="p">
<p>
Hello there, I am a millionare who brags about my journey on the internet
so people like you can sit there are marvel at my glory. Feel free to click on any
of the links below as they will take you to all of the pages you'll need to
appreciate how amazing I am:
</p>
</div>
<!--end #body--></div>
</body>
</html>



When posting code in the forum, please use the code tags, &#91;code&#93;&#91;/code&#93; - available with the # button in the post edit window.
This will wrap your code in a scroll box which greatly helps the readability of your post.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum