Saturday, March 8, 2014

How to Center a Website With CSS

<!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>
  <style type="text/css">
#content  
{
backgroun-color:red;
margin:0 auto;
width: 250px;
height: 70px;

}
  </style>
  </head>
  <body>
    <div id="content"> ... content ...gdfggggggggggggg</div>
  </body>
</html>
Note: in the above example margin 0 auto will place the elemnt in the center of the webpage..i.e only horizonatl center of the page or only x- axis center:


No comments:

Post a Comment