Jump to content

Width 100% not working


mike12255

Recommended Posts

So im trying to make the header background color go across the entire width of the page but there is about 1-2px on both ends of the rectengale of white space, does anyone know why? Here is my code:

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#header{
width:100%;
height:100px;
padding:0;
background-color:#9E0511;



}
body {
margin-top:0;
background-color: #FFFFFF;
}
-->
</style></head>

<body>
<div id="header" >
Testing

</div>
</body>
</html>

Link to comment
Share on other sites

First off:

 

<style type="text/css">
<!--
#header{
width:100%;
height:100px;
padding:0;
background-color:#9E0511;



}
body {
   margin-top:0;
   background-color: #FFFFFF;
}
-->
</style>

 

You don't need

<!--

 

and

 

-->

 

Those were originally for javascript, not CSS, and you don't even need them for javascript anymore. So you can take them out.

 

But that won't fix your problem. You should be able to fix your problem by setting the padding to 0 (zero) on the body.

Link to comment
Share on other sites

body {

  margin:0;

  background-color: #FFFFFF;

}

 

that will do it also

in case you didn't know..

 

margin: 0; will give 0px to top left right and bottom

 

margin: 0 0; is the same but the first 0 represents both top and bottomt and the 2nd 0 is left and right

 

or you could go right out with

 

margin: 0 0 0 0; think of it as a clock the order is Top right bottom left.

 

 

** i may have the orders mixed up been a while since i played with them

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.