Skip to content Skip to sidebar Skip to footer

Align The Table On The Center Of The Page

I just want to put the table in the middle of the page. Any help would be great.

Solution 1:

Try:

table {
    width: 50%;
    margin-left: auto;
    margin-right: auto;
}

or:

table {
    width: 200px;
    margin-left: auto;
    margin-right: auto;
}

BTW, this sets this for all tables. You might want to have the properties on a more specific selector (like table.someclass).

Solution 2:

old style is align="center":

<table width="400" border="0" cellspacing="0" cellpadding="0" align="center">

Solution 3:

To horizontally align table in the middle of the page, and also make table width fit itself automatically, try below:

table {
    width: auto;
    margin-left: auto;
    margin-right: auto;
}

Post a Comment for "Align The Table On The Center Of The Page"