Centering the content in XHTML 1.0 Strict

Discussion in 'Web Development and Programming' started by Chris, Mar 27, 2008.

  1. Chris

    Chris Regular Member

    Joined:
    Dec 27, 2007
    Messages:
    5,422
    Likes Received:
    86
    I need to center the content in XHTML 1.0 Strict. Right now, this content is placed on the left side; I want to place this in the center. How can I do that?

    I've tried text-align: center but thats not working.
     
  2. Steven

    Steven Regular Member

    Joined:
    Mar 19, 2008
    Messages:
    18
    Likes Received:
    0
    This Works...

    Code:
    <!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>
      <style type="text/css">
        body
        {
          margin-top:0px;
          margin-bottom:0px;
          text-align:center;   
        }
        .main
        {
          text-align:left;
          background:Gray;
          min-height:800px;
          width:780px;
          padding:10px;
        }
      </style>
     </head>
     <body>
      <div class="main">Hello World</div>
     </body>
    </html>
     
  3. Adam

    Adam Regular Member

    Joined:
    Mar 17, 2008
    Messages:
    164
    Likes Received:
    0
    Location:
    USA - oursrc.com
    Negative, that only works in IE. Try this instead:

    Code:
        <!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>
          <style type="text/css">
            body
            {
    	margin: 0 auto;
    	text-align: center;
            }
    
          </style>
        </head>
        <body>
    Body
        </body>
        </html>
     

Share This Page