Download presentation
Presentation is loading. Please wait.
Published byBernard McKenzie Modified over 9 years ago
1
XHTML Tables
2
Tables create little boxes in which you can place things to keep them organized. The little boxes are called table cells. Tables are created using the tag. Open your template.htm file and create the following table with me.
3
Creating a Table My First Table Name Class (cont’d) Designates a new row in the table Designates headings Designates the end this row Designates start of table
4
Creating a Table Sue sophomore Joe junior Designates a table data cell
5
Creating a Table Sally senior Specifies the end of this table
6
Table Cells table data. This element creates individual cells in a row. Content of a table goes in this element. table heading. This element is like the, but also displays the text inside the cells as centered and boldface
7
Table Tag Attributes The table tag can have attributes that specify additional formatting for the entire table. Syntax: Try different size borders on your table – try 1, 5, and 10. Tip: Set border="0" to display tables with no borders!
8
cellspacing Attribute Cell spacing controls the amount of space inserted between table cells. Syntax: Default size is 2 pixels. Experiment with cellspacing. (Don’t delete the border attribute) Try values such as 0, 1, 5, and 10 pixels.
9
cellpadding Attribute Cell padding controls the space between the table text and cell borders. Syntax: Default size is 2 pixels. Experiment with cellpadding. Try values such as 0, 1, 5, and 10 pixels.
10
cellpadding vs. cellspacing Cell Contents Cell Contents Cell Contents Cell Contents cell spacing is between the border of each cell (blue) cell padding is between a cell’s contents and its border (orange) Table borderCell border
11
Table width Attribute The syntax for specifying table size is: Size is the width of the table, either in pixels or as a percentage of the display area. Example
12
Caption Element A table caption is used to tell the reader what the table is for. The element is placed immediately after the tag. Example Figure 1 – 2004 Profit
13
Cell Alignment Attributes You can align individual cells in order to make your table more readable. Defaults Headings - centered, vertically and horizontally Cells and - centered vertically, left-aligned horizontally
14
Cell align Attributes To change the default horizontal alignment of a cell use the align=“alignment” attribute with the, or tags. Where alignment is either “left”, “right” or “center”.
15
Cell valign Attributes Another attribute, valign=“alignment” allows you to control vertical alignment of cells. Valid values for alignment are “top”, “middle”, and “bottom”.
16
align and valign values
17
Table colors You can also use style sheets to control table colors You can change colors for the entire table, or for a given row, or even a single cell using CSS.
18
Table colors Use an internal (embedded) style to change all tables Example: table {background-color:blue; color: white; } th {background-color:gold; color: navy; } caption {color: navy; } (cellspacing=“0”)
19
Table colors Use an inline style (the style attribute) to change one particular cell. Example: Cell 4
20
Empty Cell A element that has no content will not display correctly Use as the content
21
Table Summary - the start and end of a table - the start and end of a row in the table - a heading box on the table - a data cell in a table row - a description for your table
22
Attributes for border cellpadding cellspacing width align valign
23
Assignment #1 Create a calendar page for the month you were born – use caption for the month. Use styles for color. Add some text Add an image on your birthday To align the days to the top of the calendar, use. To keep a border on a blank cell, use for the text. (no breaking space)
24
Spanning Rows & Columns A basic table contains cells of data arranged in columns and rows. Sometimes the contents of a cell apply to more than one row or column. You can mark a single cell to be part of multiple rows or columns – known as spanning.
25
Spanning Rows & Columns Spanning is done by using the rowspan or colspan attributes in the or tags. Examples The number indicates the number of rows or columns to span
26
rowspan Span 1 2 3 4 1 2 34 Span
27
colspan Span 1 2 3 4 1 234 Span
28
Spanning Rows & Columns
29
Let’s create the following:
30
Set up the table: Spanning columns and rows Race Results
31
First row Runner needs to span 2 cols Runner Time Origin
32
Second row Men spans 3 rows Men 1. Peter Teagan 2:12:34 San Antonio, Texas
33
Rows 2 and 3 2. Kyle Wills 2:13:05 Billings, Montana 3. Jason Wu 2:14:28 Cutler, Colorado
34
Complete the table
35
Assignment #2 Reproduce a TV programming schedule for one week.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.