This section presents the XHTML tablea frequently used feature that organizes data into rows and columns. Our first example (Fig. J.10) uses a table with six rows and two columns to display price information for fruit.
Figure J.10. XHTML table.
(This item is displayed on pages 1344 - 1345 in the print version)
"http://www.w3.org/1999/xhtml"> 9 10
1 "1.0"?> 2 "-//W3C//DTD XHTML 1.1//EN" 3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 4 5 6 7 8 |
Creating a basic table 11 12 13 | 14 15 16 "1"width ="40%" 17 summary ="This table provides information about 18 the price of fruit"> 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
Tables are defined with the table element. Lines 1618 specify the start tag for a table element that has several attributes. The border attribute specifies the table's border width in pixels. To create a table without a border, set border to "0". This example assigns attribute width "40%", to set the table's width to 40 percent of the browser's width. A developer can also set attribute width to a specified number of pixels.
As its name implies, attribute summary (line 17) describes the table's contents. Speech devices use this attribute to make the table more accessible to users with visual impairments. The caption element (line 22) describes the table's content and helps text-based browsers interpret the table data. Text inside the tag is rendered above the table by most browsers. Attribute summary and element caption are two of many XHTML features that make Web pages more accessible to users with disabilities.
Error-Prevention Tip J.1
Try resizing the browser window to see how the width of the window affects the width of the table. |
A table has three distinct sectionshead, body and foot. The head section (or header cell) is defined with a thead element (lines 2631), which contains header information, such as column names. Each tr element (lines 2730) defines an individual table row. The columns in the head section are defined with th elements. Most browsers center text formatted by th (table header column) elements and display it in bold. Table header elements are nested inside table row elements.
The body section, or table body, contains the table's primary data. The table body (lines 3454) is defined in a tbody element. Data cells contain individual pieces of data and are defined with td (table data) elements.
The foot section (lines 5863) is defined with a tfoot (table foot) element and represents a footer. Text commonly placed in the footer includes calculation results and footnotes. Like other sections, the foot section can contain table rows and each row can contain columns.
Introduction to Computers, the Internet and World Wide Web
Introduction to C++ Programming
Introduction to Classes and Objects
Control Statements: Part 1
Control Statements: Part 2
Functions and an Introduction to Recursion
Arrays and Vectors
Pointers and Pointer-Based Strings
Classes: A Deeper Look, Part 1
Classes: A Deeper Look, Part 2
Operator Overloading; String and Array Objects
Object-Oriented Programming: Inheritance
Object-Oriented Programming: Polymorphism
Templates
Stream Input/Output
Exception Handling
File Processing
Class string and String Stream Processing
Web Programming
Searching and Sorting
Data Structures
Bits, Characters, C-Strings and structs
Standard Template Library (STL)
Other Topics
Appendix A. Operator Precedence and Associativity Chart
Appendix B. ASCII Character Set
Appendix C. Fundamental Types
Appendix D. Number Systems
Appendix E. C Legacy Code Topics
Appendix F. Preprocessor
Appendix G. ATM Case Study Code
Appendix H. UML 2: Additional Diagram Types
Appendix I. C++ Internet and Web Resources
Appendix J. Introduction to XHTML
Appendix K. XHTML Special Characters
Appendix L. Using the Visual Studio .NET Debugger
Appendix M. Using the GNU C++ Debugger
Bibliography