Controlling Table Width and Horizontal Alignment

Although the WIDTH attribute is not deprecated in the TABLE element, CSS provides an alternative (the width property) that can be used to control the width of a table. For an example of doing this, just add the following style rule to your example file:

<style type="text/css">
table {  width: 90%; }
</style>

CSS also provides an alternative to using the ALIGN attribute to center or right-align tables and table captions. In CSS, this is done by setting the left and right margins to auto, like this:

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

However, as discussed in Chapter 10, “Aligning, Floating, and Positioning,” this just doesn't work in Internet Explorer 5.5 for Windows, ...

Get Cascading Style Sheets (CSS) by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.