Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Junior Member fosters's Avatar
    Join Date
    Nov 2005
    Posts
    7
    Member #
    11765
    Hello all,

    I am wondering how to use CSS to center a table I have containing my web site using CSS. I tried to validate it and the XML code says that Margin Height and Top Margin aren't allowed. I figured out how to center the table using Dreamweaver and centering the div using the text-align-center command but when I tried to do negative margins or padding (i.e. -10 on top) it didn't work. Also, this doesn't seem like the most efficent way to center the table - I'd prefer to use CSS if it's possible.

    I would like the top of the header to align with the top of the browser bar, like on this website, instead of like my website is where it has the background border at the top of it, above the header image:

    http://www.bluekarbondesign.com/payertech

    Also, how to you get the table to center in the page without using div align=center?

    thanks
    fosters

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    The marginheight and topmargin attributes are proprietary ways of setting the page margins for the body element. They are not W3C compliant. W3C suggests using CSS as follows:
    Code:
    <body style="margin: 0px 0px 0px 0px">

  4. #3
    Junior Member fosters's Avatar
    Join Date
    Nov 2005
    Posts
    7
    Member #
    11765
    Quote Originally Posted by transio
    The marginheight and topmargin attributes are proprietary ways of setting the page margins for the body element. They are not W3C compliant. W3C suggests using CSS as follows:
    Code:
    <body style="margin: 0px 0px 0px 0px">

    That was EXACTLY what I was looking for! Thank you very much.

    ~fosters

  5. #4
    Senior Member Rince's Avatar
    Join Date
    Nov 2004
    Posts
    183
    Member #
    8318
    Easy way to center is to set the width then set the left and right margins to auto.
    Code:
    #layouttable {width: 600px; margin:0px auto 0xp auto;}
    
    <table id="layouttable" ....etc
    Or, less good css way using positioning.
    Code:
    #layouttable {position:absolute; left:50%; width:600px; margin-left:-300px; top:0px;}
    
    <table id="layouttable" ....etc


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:02 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com