21
INTRODUCTORY Tutorial 7 Creating Tables

INTRODUCTORY Tutorial 7 Creating Tables. XP New Perspectives on Blended HTML, XHTML, and CSS2 Objectives Discern the difference between data tables and

Embed Size (px)

Citation preview

INTRODUCTORY

Tutorial 7

Creating Tables

XP

New Perspectives on Blended HTML, XHTML, and CSS 2

Objectives• Discern the difference between data tables and

layout tables• Create a table to display and organize data• Merge table columns or rows• Understand how to plan and use layout tables• Create a table for layout

XPObjectives• Learn how to nest a data table within a layout

table• Create styles to change the appearance of a

table• Position the cell contents vertically• Position a table horizontally

New Perspectives on Blended HTML, XHTML, and CSS 3

XPUnderstanding the Limitations of HTML Tables• Using HTML, you must enter the code for a table

one row at a time and one cell at a time• To organize data, you create a data table, which

is a table used to align text and numbers in columns and rows

• To design pages, you can create a layout table, which is a table intended solely for page layout

• When you place a table inside another table, you are creating a nested table

New Perspectives on Blended HTML, XHTML, and CSS 4

XPCreating a Table Border• To create a table border, enter the following

code:<table border="pixelvalue">

where border is the border attribute and pixelvalue is the width of the border expressed in pixels. The higher the pixel value, the thicker the border

New Perspectives on Blended HTML, XHTML, and CSS 5

XPEntering the Title and Summary Attributes• To begin creating a table, enter the following code:<table title="tabletitle” summary="tablesummary">

</table>

where table is the start table tag, title is the title attribute, tabletitle is a brief description of the table to be used as a ScreenTip, summary is the summary attribute, tablesummary is a detailed description of the table content, and </table> is the end table tag on a separate line

New Perspectives on Blended HTML, XHTML, and CSS 6

XPCreating a Table Caption• To create a table caption, enter the following

code:<caption>captiontext</caption>

where caption is the start caption tag, captiontext is the text in the caption, and </caption> is the end caption tag. If you want to position the caption below the table, insert the align attribute into the caption tag and assign the value of bottom

New Perspectives on Blended HTML, XHTML, and CSS 7

XPCreating Table Rows• To create table rows, enter the following code:<tr>

<td>tabledata</td>

</tr>

where <tr> is the start table row tag, td is the start table data tag, tabledata is the data for the cell, </td> is the end table data tag, and </tr> is the end table row tag

• Most HTML tables have one or more rows used for the column headers, which by default make the text in the header centered and bold

• Use the optional table header tags, <th> and </th>, to create table headers

New Perspectives on Blended HTML, XHTML, and CSS 8

XPSpanning Cells Across Columns• To span a cell across columns, enter the

following code:<td colspan="value">

where colspan is the colspan attribute and value is the number of columns that will be spanned. The colspan attribute and its value must be placed in the cell in which the colspan should begin. All empty spanned table data cells should be deleted

New Perspectives on Blended HTML, XHTML, and CSS 9

XPMerging Cells in Rows• To span a cell across rows, enter the following code:<td rowspan="value">

where rowspan is the rowspan attribute and value is the number of rows that will be spanned. The rowspan attribute and its value must be placed in the cell in which the rowspan should begin. All empty spanned table data cells should be deleted. If a row containing a rowspan is formatted, the row will include all the cells horizontally and the merged cells vertically

New Perspectives on Blended HTML, XHTML, and CSS 10

XPMerging Cells in Rows

New Perspectives on Blended HTML, XHTML, and CSS 11

XPUsing Tables for Layout

New Perspectives on Blended HTML, XHTML, and CSS 12

XPUsing Tables for Layout

New Perspectives on Blended HTML, XHTML, and CSS 13

XPInserting Comments into the Table

New Perspectives on Blended HTML, XHTML, and CSS 14

XPRemoving the Table Border• Now that the placeholder text has been replaced

with actual data, you no longer need to display the nested data table border

New Perspectives on Blended HTML, XHTML, and CSS 15

XPUsing CSS with Tables• Because the layout table occupies the entire

body section, almost all styles you create for the table will supersede any styles you create for the body

New Perspectives on Blended HTML, XHTML, and CSS 16

XPUsing CSS with Tables

New Perspectives on Blended HTML, XHTML, and CSS 17

XPUsing CSS with Tables

New Perspectives on Blended HTML, XHTML, and CSS 18

XPStriping Rows• Many tables mimic the appearance of computer

printout where each row has an alternating background color, making the rows easier to locate and read

New Perspectives on Blended HTML, XHTML, and CSS 19

XPFormatting Columns

New Perspectives on Blended HTML, XHTML, and CSS 20

XPUsing CSS with Tables

New Perspectives on Blended HTML, XHTML, and CSS 21