HTML and CSS Reference
In-Depth Information
FiGure 17-4
aLiGninG TabLes
To align your table on the page — left, right, or center — you need to use the same CSS techniques
for aligning other page elements like <div> tags. For example, if you wanted to make sure that your
table was centered, you'd apply the margin property to the table, like this:
table {
margin: 20px auto;
As shown in Figure 17-5, the table is centered between the automatically determined left and right
margins. The first value (here, 20px ), which determines the top and bottom margins, can be 0 or
any other measurement.
FiGure 17-5
If the table is within a containing element other than the <body> tag, the con-
tainer needs to have a declared width for the CSS margin property declaration to
align tables properly. Otherwise, the full page width is assumed and the table is
aligned according to the full browser window.
Search WWH ::

Custom Search