Book HomeCascading Style Sheets: The Definitive GuideSearch this book Thursday 05th of March 2015 11:17:46 AM

10.7. Tables

Perhaps as a result of a generic need to be able to describe table layout -- something CSS1 lacks -- CSS2 includes a handful of features that apply directly to tables and table cells. First, there are 10 new table-related values for display:

table
inline-table
table-column-group
table-column
table-row-group
table-row
table-cell
table-caption
table-header-group
table-footer-group 

While the effects of most of these are obvious from their names, at least two may not be familiar to you. table-header-group and table-footer-group are used to mark the header and footer of a table. These are displayed, respectively, above or below all the rows of the table, but not outside of the table's caption.

Another interesting effect is that you can align text on a character by using the text-align property. For example, if you wanted to line up a column of figures on a decimal point, you might declare:

TD { text-align: "." }

As long as a set of cells are grouped into a column, their content will be aligned so that the periods all line up along a vertical axis.

Far from relying on existing properties, CSS2 provides a whole array of brand-new properties in the table section. Here are a few of them:

There are also properties describing how visibility and vertical-align are applied to tables. There is also a caption-side property, which functions exactly the "tall" text is aligned in Figure 8-54.

Figure 8-54

Figure 8-54. Top-aligning text

What's happened here is that the top of the "tall" text's inline box is aligned with the top of the line box. Since the "tall" text has equal values for font-size and line-height, its content height and inline box are the same thing. However, consider this:

same as the ALIGN attribute on the <CAPTION>
tag, and the property speak-header-cell, which controls how header cells are handled by speech-generating browsers (more on that later).



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.

6. A floating element's top may not be higher thanthe top of any line box with content that precedes the floatingelement.

Similar to rules 4 and 5, this further limits the upward floating ofan element by preventing it from being above the top of a linecontaining content that precedes the floated element. Let's saythat, right in the middle of a paragraph, there is a floated image.The highest the top of that image may be placed is the top of theline box from which the image originates. As you can see in Figure 8-35, this keeps images from floating too farand Incline.

If you wanted to make sure that a document uses italic text infamiliar ways, you could write a style sheet like this:

P {font-style: normal;}EM, I {font-style: italic;}

As we can see in Figure 5-25, these styles wouldmake paragraphs use an upright font, as usual, and cause thedocument, composed of no more than a few paragraphs and H3 elements, where the first paragraph contains a floated image. Further, this floated image has a right margin of five pixels (5px). You would expect the document to be rendered very much as shown in Figure 7-67.

Figure 7-67

Figure 7-67. Floating an image

Nothing unusual there, of course, but look what happens when we set the first paragraph to have a background, as has been done in Figure 7-68.

All of the advantages of XML outlined so far all make interoperability possible. This is one of the most important requirements for XML, to enable disparate systems to be able to share information easily.

By taking the lowest common denominator approach, by being web enabled, protocol independent, network independent, platform independent and extensible, XML makes it possible for new systems and old systems (that are all different) to communicate with each other. Encoding information in plain text with tags is better than using propietary and platform dependent binary formats.

Vision

XML provides solutions for problems that have existed for the past 20 years. With most applications and software services using the Internet as a target platform for deployment, XML could not have come at a better time. With the web becoming so popular, a new paradigm of computing has emerged for which XML supplies one of the most important pieces, platform, vendor and application neutral data. Regardless of the programming language used to process XML, it will enable this new networked computing world.