Reputation: 97
I want to set the width of the body to 650px. But its not happening. Simple css code.
body{
width:650px;
background-color:red;
}
My HTML code!
<html>
<head>
<link rel="stylesheet" type="text/css" href="content.css">
</head>
<body>
<h1>Login Successful <?php echo $_SESSION['username']?></h1>
</body>
</html>
I am getting the red color according to the code but not getting the width, as you see the pic.
Upvotes: 0
Views: 515
Reputation:
You need to wrap the page by div
tag and set the height
.wrapper{
width:650px;
height:500px;
background-color:red;
}
<body>
<div class="wrapper">
<h1>Login Successful <?php echo $_SESSION['username']?></h1>
</div>
</body>
Upvotes: 2
Reputation: 27624
Your body width is 650px
for All content elements
.
But body is magic element to set background-color
all including outside margin.
Check this jsfiddle demo , for show you border property to see difference,
But now same things you can done use div element
inside body and apply width or background-color to check this Demo jsFiddle difference.
Upvotes: 2
Reputation: 10111
The <body>
element is magic. Wrap your page in a <div>
and style that instead.
Upvotes: 0