SlideShare a Scribd company logo
1 of 37
Principles of Web Design
5th Edition
Chapter Ten
Data Tables
Objectives
When you complete this chapter, you will be able to:
• Use table elements
• Use table headers and footers
• Group columns
• Style table borders
• Apply padding, margins, and floats to tables
• Style table background colors
• Apply table styles
2
Principles of Web Design 5th Ed.
3
Using Table Elements
• The HTML table elements allow the
arrangement of data into rows of cells and
columns
• The table element <table> contains the table
information, which consists of:
– Header element <th>
– Row element <tr>
– Data cell alignment <td>
Principles of Web Design 5th Ed.
Principles of Web Design 5th Ed. 4
Principles of Web Design 5th Ed. 5
Collapsing Table Borders
• Tables are more legible with the table borders
collapsed
• Use the border-collapsed property
table {border-collapse: collapse;}
Principles of Web Design 5th Ed. 6
Principles of Web Design 5th Ed. 7
Spanning Rows
• The rowspan attribute lets you create cells that
span multiple rows
<td class="title" rowspan="6">
Best-Selling Albums Worldwide</td>
Principles of Web Design 5th Ed. 8
Principles of Web Design 5th Ed. 9
Using Table Headers and Footers
• Rows can be grouped into head, body, and footer
sections using the <thead>, <tbody>, and <tfoot>
elements
• You can style these table sections with CSS
Principles of Web Design 5th Ed. 10
Using Table Headers and Footers
thead {
font-family: arial;
background-color: #ccddee;
}
tfoot {
background-color: #ddccee;
font-family: times, serif;
font-size: .9em;
font-style: italic;
}
Principles of Web Design 5th Ed. 11
Principles of Web Design 5th Ed. 12
Grouping Columns
• The <colgroup> and <col> elements allow you to
apply style characteristics to groups of columns or
individual columns
• The <colgroup> element has a span attribute that
lets you set the number of columns specified in the
group
• The <col> element lets you specify style
characteristics for individual columns
Principles of Web Design 5th Ed. 13
Principles of Web Design 5th Ed. 14
Principles of Web Design 5th Ed. 15
Styling the Caption
• You can position the caption on the top or bottom
of the table using the caption-site property
• You can also apply other style properties to
enhance the caption text:
caption {text-align: left;
font-style: italic;
padding-bottom: 10px;
}
Principles of Web Design 5th Ed. 16
Principles of Web Design 5th Ed. 17
Styling Table Borders
• By default, table borders are turned off
• You can add borders using CSS
• Borders can be applied to the whole table, to
individual rows, and to individual cells
Principles of Web Design 5th Ed. 18
Styling Table Borders
• To create a table with an outside border only:
table {
border: solid 1px black;
border-collapse: collapse;
}
Principles of Web Design 5th Ed. 19
Principles of Web Design 5th Ed. 20
Styling Table Borders
• To specify borders for each cell, use a separate
style rule:
table {
border: solid 1px black;
border-collapse: collapse;
}
th, td {
border: solid 1px black;
}
Principles of Web Design 5th Ed. 21
Principles of Web Design 5th Ed. 22
Styling Table Borders
• You can also style individual rows or cells and
apply cell borders
th {
border-bottom: solid thick blue;
background-color: #ccddee;
}
Principles of Web Design 5th Ed. 23
Principles of Web Design 5th Ed. 24
Applying Padding, Margins, and
Floats to Tables
Using Padding
• You can enhance the legibility of your table data
with padding
• This style rule adds five pixels of padding to both
types of table data elements
th, td {padding: 5px;}
Principles of Web Design 5th Ed. 26
Principles of Web Design 5th Ed. 27
Using Margins and Floats
• Tables can be floated
• Use margins to add white space around floating
tables
table.best {
font-family: verdana;
border: solid 1px black;
border-collapse: collapse;
float: left;
margin-right: 20px;
margin-bottom: 10px;
}
Principles of Web Design 5th Ed. 28
Principles of Web Design 5th Ed. 29
Styling Table Background Colors
• You can apply background colors to:
– Entire table
– Single rows or cells
– Column groups of individual columns
• You can alternate colors for different rows
• Add hover interactions
Principles of Web Design 5th Ed. 30
Principles of Web Design 5th Ed. 31
Creating Alternate Color Rows
• Table data is easier to read when alternate rows
have a distinguishing background color
• Write a style rule for the odd or even row using a
class selector
tr.odd td {background-color: #eaead5;}
Principles of Web Design 5th Ed. 32
Principles of Web Design 5th Ed. 33
Creating Background Hover Effects
• You can add interactivity to your table with hover
effects
• When the user hovers the pointer over a cell or
row, the formatting can change
td:hover {
color: white;
background-color: #722750;
}
Principles of Web Design 5th Ed. 34
Principles of Web Design 5th Ed. 35
Summary
• Use tables for presentation of data, not for page
layout
• Use the grouping elements to apply styles to
groups of rows or columns or to the header, body,
and footer of a table
• Apply borders to both the <table> and cell (<th>
and <td>) elements to display a table border on the
entire table
• Use the border-collapse property to make table
data more legible
Principles of Web Design 5th Ed. 36
Summary
• Always use CSS to add presentation style to tables
• Use padding to add space within your cells to make
your data more legible
• You can float tables and add margins with the box
model properties
• Specify background colors or hovers to aid in the
legibility of your data
Principles of Web Design 5th Ed. 37

More Related Content

Similar to 9781111528705_PPT_ch10.ppt

basic programming language AND HTML CSS JAVApdf
basic programming language AND HTML CSS JAVApdfbasic programming language AND HTML CSS JAVApdf
basic programming language AND HTML CSS JAVApdfelayelily
 
Chapter 6 Working with Tables and Columns
Chapter 6 Working with Tables and ColumnsChapter 6 Working with Tables and Columns
Chapter 6 Working with Tables and ColumnsDr. Ahmed Al Zaidy
 
Lesson 5 cs5
Lesson 5   cs5Lesson 5   cs5
Lesson 5 cs5dtelepos
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheetssmitha273566
 
9781111528705_PPT_ch09.ppt
9781111528705_PPT_ch09.ppt9781111528705_PPT_ch09.ppt
9781111528705_PPT_ch09.pptSimonChirambira
 
CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout Rachel Andrew
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheetssmithaps4
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation Salman Memon
 
9781111528705_PPT_ch013.pptx
9781111528705_PPT_ch013.pptx9781111528705_PPT_ch013.pptx
9781111528705_PPT_ch013.pptxSimonChirambira
 

Similar to 9781111528705_PPT_ch10.ppt (20)

Ppt ch05
Ppt ch05Ppt ch05
Ppt ch05
 
basic programming language AND HTML CSS JAVApdf
basic programming language AND HTML CSS JAVApdfbasic programming language AND HTML CSS JAVApdf
basic programming language AND HTML CSS JAVApdf
 
Chapter 6 Working with Tables and Columns
Chapter 6 Working with Tables and ColumnsChapter 6 Working with Tables and Columns
Chapter 6 Working with Tables and Columns
 
Ddpz2613 topic4 table
Ddpz2613 topic4 tableDdpz2613 topic4 table
Ddpz2613 topic4 table
 
Layouts
Layouts Layouts
Layouts
 
Lesson 5 cs5
Lesson 5   cs5Lesson 5   cs5
Lesson 5 cs5
 
Ppt ch04
Ppt ch04Ppt ch04
Ppt ch04
 
Ppt ch04
Ppt ch04Ppt ch04
Ppt ch04
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
 
9781111528705_PPT_ch09.ppt
9781111528705_PPT_ch09.ppt9781111528705_PPT_ch09.ppt
9781111528705_PPT_ch09.ppt
 
CSS
CSSCSS
CSS
 
CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout
 
Css
CssCss
Css
 
Cascading style sheets
Cascading style sheetsCascading style sheets
Cascading style sheets
 
Css Basics
Css BasicsCss Basics
Css Basics
 
CSS Grid Layout
CSS Grid LayoutCSS Grid Layout
CSS Grid Layout
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation
 
Ddpz2613 topic6 frame
Ddpz2613 topic6 frameDdpz2613 topic6 frame
Ddpz2613 topic6 frame
 
CSS
CSSCSS
CSS
 
9781111528705_PPT_ch013.pptx
9781111528705_PPT_ch013.pptx9781111528705_PPT_ch013.pptx
9781111528705_PPT_ch013.pptx
 

More from SimonChirambira

9781111528705_PPT_ch03.ppt
9781111528705_PPT_ch03.ppt9781111528705_PPT_ch03.ppt
9781111528705_PPT_ch03.pptSimonChirambira
 
9781111528705_PPT_ch07.ppt
9781111528705_PPT_ch07.ppt9781111528705_PPT_ch07.ppt
9781111528705_PPT_ch07.pptSimonChirambira
 
9781111528705_PPT_ch11.ppt
9781111528705_PPT_ch11.ppt9781111528705_PPT_ch11.ppt
9781111528705_PPT_ch11.pptSimonChirambira
 
9781111528705_PPT_ch08.ppt
9781111528705_PPT_ch08.ppt9781111528705_PPT_ch08.ppt
9781111528705_PPT_ch08.pptSimonChirambira
 
9781111528705_PPT_ch012.pptx
9781111528705_PPT_ch012.pptx9781111528705_PPT_ch012.pptx
9781111528705_PPT_ch012.pptxSimonChirambira
 
9781111528705_PPT_ch014.pptx
9781111528705_PPT_ch014.pptx9781111528705_PPT_ch014.pptx
9781111528705_PPT_ch014.pptxSimonChirambira
 
9781111528705_PPT_ch01.pptx
9781111528705_PPT_ch01.pptx9781111528705_PPT_ch01.pptx
9781111528705_PPT_ch01.pptxSimonChirambira
 

More from SimonChirambira (7)

9781111528705_PPT_ch03.ppt
9781111528705_PPT_ch03.ppt9781111528705_PPT_ch03.ppt
9781111528705_PPT_ch03.ppt
 
9781111528705_PPT_ch07.ppt
9781111528705_PPT_ch07.ppt9781111528705_PPT_ch07.ppt
9781111528705_PPT_ch07.ppt
 
9781111528705_PPT_ch11.ppt
9781111528705_PPT_ch11.ppt9781111528705_PPT_ch11.ppt
9781111528705_PPT_ch11.ppt
 
9781111528705_PPT_ch08.ppt
9781111528705_PPT_ch08.ppt9781111528705_PPT_ch08.ppt
9781111528705_PPT_ch08.ppt
 
9781111528705_PPT_ch012.pptx
9781111528705_PPT_ch012.pptx9781111528705_PPT_ch012.pptx
9781111528705_PPT_ch012.pptx
 
9781111528705_PPT_ch014.pptx
9781111528705_PPT_ch014.pptx9781111528705_PPT_ch014.pptx
9781111528705_PPT_ch014.pptx
 
9781111528705_PPT_ch01.pptx
9781111528705_PPT_ch01.pptx9781111528705_PPT_ch01.pptx
9781111528705_PPT_ch01.pptx
 

Recently uploaded

西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造kbdhl05e
 
Call Girls Aslali 7397865700 Ridhima Hire Me Full Night
Call Girls Aslali 7397865700 Ridhima Hire Me Full NightCall Girls Aslali 7397865700 Ridhima Hire Me Full Night
Call Girls Aslali 7397865700 Ridhima Hire Me Full Nightssuser7cb4ff
 
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一F dds
 
Call Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts Service
Call Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts ServiceCall Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts Service
Call Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts Servicejennyeacort
 
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)jennyeacort
 
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一z xss
 
办理学位证(TheAuckland证书)新西兰奥克兰大学毕业证成绩单原版一比一
办理学位证(TheAuckland证书)新西兰奥克兰大学毕业证成绩单原版一比一办理学位证(TheAuckland证书)新西兰奥克兰大学毕业证成绩单原版一比一
办理学位证(TheAuckland证书)新西兰奥克兰大学毕业证成绩单原版一比一Fi L
 
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书zdzoqco
 
Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`
Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`
Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`dajasot375
 
Cosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable BricksCosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable Bricksabhishekparmar618
 
Passbook project document_april_21__.pdf
Passbook project document_april_21__.pdfPassbook project document_april_21__.pdf
Passbook project document_april_21__.pdfvaibhavkanaujia
 
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Servicejennyeacort
 
2024新版美国旧金山州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
2024新版美国旧金山州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree2024新版美国旧金山州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
2024新版美国旧金山州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degreeyuu sss
 
Introduction-to-Canva-and-Graphic-Design-Basics.pptx
Introduction-to-Canva-and-Graphic-Design-Basics.pptxIntroduction-to-Canva-and-Graphic-Design-Basics.pptx
Introduction-to-Canva-and-Graphic-Design-Basics.pptxnewslab143
 
3D Printing And Designing Final Report.pdf
3D Printing And Designing Final Report.pdf3D Printing And Designing Final Report.pdf
3D Printing And Designing Final Report.pdfSwaraliBorhade
 
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一diploma 1
 
Architecture case study India Habitat Centre, Delhi.pdf
Architecture case study India Habitat Centre, Delhi.pdfArchitecture case study India Habitat Centre, Delhi.pdf
Architecture case study India Habitat Centre, Delhi.pdfSumit Lathwal
 

Recently uploaded (20)

西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造
 
Call Girls Aslali 7397865700 Ridhima Hire Me Full Night
Call Girls Aslali 7397865700 Ridhima Hire Me Full NightCall Girls Aslali 7397865700 Ridhima Hire Me Full Night
Call Girls Aslali 7397865700 Ridhima Hire Me Full Night
 
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
 
Call Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts Service
Call Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts ServiceCall Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts Service
Call Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts Service
 
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
 
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
 
办理学位证(TheAuckland证书)新西兰奥克兰大学毕业证成绩单原版一比一
办理学位证(TheAuckland证书)新西兰奥克兰大学毕业证成绩单原版一比一办理学位证(TheAuckland证书)新西兰奥克兰大学毕业证成绩单原版一比一
办理学位证(TheAuckland证书)新西兰奥克兰大学毕业证成绩单原版一比一
 
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
 
Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`
Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`
Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`
 
Cosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable BricksCosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable Bricks
 
Passbook project document_april_21__.pdf
Passbook project document_april_21__.pdfPassbook project document_april_21__.pdf
Passbook project document_april_21__.pdf
 
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
 
2024新版美国旧金山州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
2024新版美国旧金山州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree2024新版美国旧金山州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
2024新版美国旧金山州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
Cheap Rate ➥8448380779 ▻Call Girls In Iffco Chowk Gurgaon
Cheap Rate ➥8448380779 ▻Call Girls In Iffco Chowk GurgaonCheap Rate ➥8448380779 ▻Call Girls In Iffco Chowk Gurgaon
Cheap Rate ➥8448380779 ▻Call Girls In Iffco Chowk Gurgaon
 
Introduction-to-Canva-and-Graphic-Design-Basics.pptx
Introduction-to-Canva-and-Graphic-Design-Basics.pptxIntroduction-to-Canva-and-Graphic-Design-Basics.pptx
Introduction-to-Canva-and-Graphic-Design-Basics.pptx
 
3D Printing And Designing Final Report.pdf
3D Printing And Designing Final Report.pdf3D Printing And Designing Final Report.pdf
3D Printing And Designing Final Report.pdf
 
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
 
Architecture case study India Habitat Centre, Delhi.pdf
Architecture case study India Habitat Centre, Delhi.pdfArchitecture case study India Habitat Centre, Delhi.pdf
Architecture case study India Habitat Centre, Delhi.pdf
 
Call Girls in Pratap Nagar, 9953056974 Escort Service
Call Girls in Pratap Nagar,  9953056974 Escort ServiceCall Girls in Pratap Nagar,  9953056974 Escort Service
Call Girls in Pratap Nagar, 9953056974 Escort Service
 

9781111528705_PPT_ch10.ppt

  • 1. Principles of Web Design 5th Edition Chapter Ten Data Tables
  • 2. Objectives When you complete this chapter, you will be able to: • Use table elements • Use table headers and footers • Group columns • Style table borders • Apply padding, margins, and floats to tables • Style table background colors • Apply table styles 2 Principles of Web Design 5th Ed.
  • 3. 3 Using Table Elements • The HTML table elements allow the arrangement of data into rows of cells and columns • The table element <table> contains the table information, which consists of: – Header element <th> – Row element <tr> – Data cell alignment <td> Principles of Web Design 5th Ed.
  • 4. Principles of Web Design 5th Ed. 4
  • 5. Principles of Web Design 5th Ed. 5
  • 6. Collapsing Table Borders • Tables are more legible with the table borders collapsed • Use the border-collapsed property table {border-collapse: collapse;} Principles of Web Design 5th Ed. 6
  • 7. Principles of Web Design 5th Ed. 7
  • 8. Spanning Rows • The rowspan attribute lets you create cells that span multiple rows <td class="title" rowspan="6"> Best-Selling Albums Worldwide</td> Principles of Web Design 5th Ed. 8
  • 9. Principles of Web Design 5th Ed. 9
  • 10. Using Table Headers and Footers • Rows can be grouped into head, body, and footer sections using the <thead>, <tbody>, and <tfoot> elements • You can style these table sections with CSS Principles of Web Design 5th Ed. 10
  • 11. Using Table Headers and Footers thead { font-family: arial; background-color: #ccddee; } tfoot { background-color: #ddccee; font-family: times, serif; font-size: .9em; font-style: italic; } Principles of Web Design 5th Ed. 11
  • 12. Principles of Web Design 5th Ed. 12
  • 13. Grouping Columns • The <colgroup> and <col> elements allow you to apply style characteristics to groups of columns or individual columns • The <colgroup> element has a span attribute that lets you set the number of columns specified in the group • The <col> element lets you specify style characteristics for individual columns Principles of Web Design 5th Ed. 13
  • 14. Principles of Web Design 5th Ed. 14
  • 15. Principles of Web Design 5th Ed. 15
  • 16. Styling the Caption • You can position the caption on the top or bottom of the table using the caption-site property • You can also apply other style properties to enhance the caption text: caption {text-align: left; font-style: italic; padding-bottom: 10px; } Principles of Web Design 5th Ed. 16
  • 17. Principles of Web Design 5th Ed. 17
  • 18. Styling Table Borders • By default, table borders are turned off • You can add borders using CSS • Borders can be applied to the whole table, to individual rows, and to individual cells Principles of Web Design 5th Ed. 18
  • 19. Styling Table Borders • To create a table with an outside border only: table { border: solid 1px black; border-collapse: collapse; } Principles of Web Design 5th Ed. 19
  • 20. Principles of Web Design 5th Ed. 20
  • 21. Styling Table Borders • To specify borders for each cell, use a separate style rule: table { border: solid 1px black; border-collapse: collapse; } th, td { border: solid 1px black; } Principles of Web Design 5th Ed. 21
  • 22. Principles of Web Design 5th Ed. 22
  • 23. Styling Table Borders • You can also style individual rows or cells and apply cell borders th { border-bottom: solid thick blue; background-color: #ccddee; } Principles of Web Design 5th Ed. 23
  • 24. Principles of Web Design 5th Ed. 24
  • 25. Applying Padding, Margins, and Floats to Tables
  • 26. Using Padding • You can enhance the legibility of your table data with padding • This style rule adds five pixels of padding to both types of table data elements th, td {padding: 5px;} Principles of Web Design 5th Ed. 26
  • 27. Principles of Web Design 5th Ed. 27
  • 28. Using Margins and Floats • Tables can be floated • Use margins to add white space around floating tables table.best { font-family: verdana; border: solid 1px black; border-collapse: collapse; float: left; margin-right: 20px; margin-bottom: 10px; } Principles of Web Design 5th Ed. 28
  • 29. Principles of Web Design 5th Ed. 29
  • 30. Styling Table Background Colors • You can apply background colors to: – Entire table – Single rows or cells – Column groups of individual columns • You can alternate colors for different rows • Add hover interactions Principles of Web Design 5th Ed. 30
  • 31. Principles of Web Design 5th Ed. 31
  • 32. Creating Alternate Color Rows • Table data is easier to read when alternate rows have a distinguishing background color • Write a style rule for the odd or even row using a class selector tr.odd td {background-color: #eaead5;} Principles of Web Design 5th Ed. 32
  • 33. Principles of Web Design 5th Ed. 33
  • 34. Creating Background Hover Effects • You can add interactivity to your table with hover effects • When the user hovers the pointer over a cell or row, the formatting can change td:hover { color: white; background-color: #722750; } Principles of Web Design 5th Ed. 34
  • 35. Principles of Web Design 5th Ed. 35
  • 36. Summary • Use tables for presentation of data, not for page layout • Use the grouping elements to apply styles to groups of rows or columns or to the header, body, and footer of a table • Apply borders to both the <table> and cell (<th> and <td>) elements to display a table border on the entire table • Use the border-collapse property to make table data more legible Principles of Web Design 5th Ed. 36
  • 37. Summary • Always use CSS to add presentation style to tables • Use padding to add space within your cells to make your data more legible • You can float tables and add margins with the box model properties • Specify background colors or hovers to aid in the legibility of your data Principles of Web Design 5th Ed. 37