rodrigo3n
rodrigo3n

Reputation: 123

How to insert a margin at the right and left of the page?

I want to insert this margin, but I don't know why... I want it to be like Twitter or TwitPic

My CSS:

 body {
        margin: 40px;
        margin-bottom: 50px;
        padding: 0;
        background-color: #edece9;
        font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
        font-size: 13px;
        color: #333;
      }

Upvotes: 0

Views: 2963

Answers (3)

Jake McGraw
Jake McGraw

Reputation: 56106

Assuming a page structure like so:

<!DOCTYPE html>
<html>
  <head>
    <link type="text/css" rel="stylesheet" href="style.css" />
  </head>
  <body>
    <div id="main">
    </div>
  </body>
</html>

Then style.css should look like:

* {margin:0;}
div#main {
  width:800px;
  margin:0 auto;
}

Upvotes: 1

Gregoire
Gregoire

Reputation: 24832

you need to put a div with a fixed with (your desired page width and put its margin:0 auto

Upvotes: 0

knittl
knittl

Reputation: 265151

twitter uses a fixed-width div which uses margin-left:auto; and margin-right:auto. this will center the div horizontally

Upvotes: 0

Related Questions