SlideShare a Scribd company logo
HTML Tables
Lecture Overview
 Learn about the basics of tables
 Create simple 2-dimensional tables
 Format tables
 Create tables with complex structures
Introduction to Tables (1)
 Tables are grids made up of rows and columns
 The intersection of a row and column is called a
cell
 Tables can contain
 Text
 Additional markup
 Other tables
 Images
 And just about anything else
 Tables are block-level elements
Introduction to Tables (2)
 Much has changed about tables from HTML 4
to HTML 5
 Use tables to render truly tabular data
 Use CSS for presentation
 In this regard, CSS has replaced some table
functionality
 I’ll use the new constructs in this lecture to
support good habits
Basic Table Tags
 The <table> tag is the outermost tag and
marks the table
 The deprecated border attribute defines the
width of the border surrounding the table
 The <tr> tag appears inside the <table>
tag and marks a table row
 The <td> tag appears inside the <tr> tag
and marks the table data (cell)
Basic Table Tags (Example)
 Create a table with a 2-pixel border
<table border=“2”>
<tr>
<td>Column 1</td>
<td>Column 2</td>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
Basic Table Tags (Example)
 Create a table with a 2-pixel border
Tables (Captions and Headers)
 The <caption> element appears as a child
of a <table> and contains the table’s title
 The caption appears just above the table itself
 The <th> element is similar to the <tr>
element but contains the table’s header
 The header is typically emphasized
Tables (Captions and Headers
/ Example)
<table border="2">
<caption>Monthly Savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
Tables (Grouping)
 The <thead>, <tfoot>, and <tbody> tags
are used to group table parts
 Header, footer, body
 Note that <tfoot> MUST appear after
<tbody>
 It’s used for dynamic table scrolling, which
most browsers do not yet support
 These are also logical (semantic) rather than
physical elements
<table> (Attributes)
 The border attribute defines the thickness of the
table’s border
 Value is measured in pixels
 The cellpadding attribute defines the number of
pixels from the cell wall to the cell content
 The cellspacing attribute defines the number of
pixels between cells
 We typically do this with CSS but we have not
discussed CSS yet
<table>
(Attributes)
Column and Cell Attributes
 align – justify the text within the columns
 left, right center
 width – the width of the column
 Use relative or absolute widths
 width=“25%” - 25% of the table
 width=“100px” - 100 pixels
 valign – vertical alignment
 Values: top, middle, bottom, baseline
 Supported by tables too
 See example
<table> Columns
 The <col> tag appears as a child of the
<table> or <colgroup> tag and describes
formatting for the entire column
 It’s often easier than formatting individual rows
or cells
 The <colgroup> tag is used to apply
formatting to several columns
<table> Columns (Example)
 Center the data in the first column and right
justify the second column
<table border="1">
<col align="center" />
<col align="right" />
. . .
Cell Spanning
 Some tables have cells that should span
multiple rows and columns
 rowSpan attribute is used to create a cell that
spans multiple rows
 colspan attribute is used to create a cell that
spans multiple columns
Cell Spanning (Illustration)
Tables within Tables
 That said, tables can contain tables, which
can contain tables.
 The process can get very complicated
Table Formatting and CSS
 We have not discussed CSS yet but I want to
mention it here
 Everything is a box in the eyes of CSS
 A table is a box
 A table row is a box
 A table cell is a box
 A nested table is just another box
Table Formatting and CSS
 Borderstyle is used to set the border of a cell,
row or the table
 All margin and padding works as you would
expect
Table Formatting (Conflicts)
 Cell formatting overrides row formatting
 Row formatting overrides table formatting
 See the chapter’s example
// 21

More Related Content

Similar to HTML Tables.ppt

Web design - Working with tables in HTML
Web design - Working with tables in HTMLWeb design - Working with tables in HTML
Web design - Working with tables in HTML
Mustafa Kamel Mohammadi
 
htmltables-180721142906-1.pptx
htmltables-180721142906-1.pptxhtmltables-180721142906-1.pptx
htmltables-180721142906-1.pptx
HemantBansal35
 
Lecture-4.pptx
Lecture-4.pptxLecture-4.pptx
Lecture-4.pptx
vishal choudhary
 
Tables
TablesTables
Tables
savitamhaske
 
Web I - 03 - Tables
Web I - 03 - TablesWeb I - 03 - Tables
Web I - 03 - Tables
Randy Connolly
 
Table structure introduction
Table structure introductionTable structure introduction
Table structure introduction
nobel mujuji
 
v4-html-table-210321161424.pptx
v4-html-table-210321161424.pptxv4-html-table-210321161424.pptx
v4-html-table-210321161424.pptx
HemantBansal35
 
Working With Tables in HTML
Working With Tables in HTMLWorking With Tables in HTML
Working With Tables in HTML
Shehzad Yaqoob
 
html-table
html-tablehtml-table
html-table
Dhirendra Chauhan
 
Computer language - Html tables
Computer language - Html tablesComputer language - Html tables
Computer language - Html tables
Dr. I. Uma Maheswari Maheswari
 
HTML Tables
HTML TablesHTML Tables
HTML Tables
Nisa Soomro
 
Html web designing using tables
Html web designing using tablesHtml web designing using tables
Html web designing using tables
Jesus Obenita Jr.
 
Html tables
Html tablesHtml tables
Html tables
Himanshu Pathak
 
Html_Day_Three(W3Schools)
Html_Day_Three(W3Schools)Html_Day_Three(W3Schools)
Html_Day_Three(W3Schools)
Rafi Haidari
 
table html web programing
table  html  web programingtable  html  web programing
table html web programing
lodhran-hayat
 
Html table tags
Html table tagsHtml table tags
Html table tags
eShikshak
 
Table and Form HTML&CSS
Table and Form HTML&CSSTable and Form HTML&CSS
Table and Form HTML&CSS
Yaowaluck Promdee
 

Similar to HTML Tables.ppt (20)

Web design - Working with tables in HTML
Web design - Working with tables in HTMLWeb design - Working with tables in HTML
Web design - Working with tables in HTML
 
htmltables-180721142906-1.pptx
htmltables-180721142906-1.pptxhtmltables-180721142906-1.pptx
htmltables-180721142906-1.pptx
 
Lecture-4.pptx
Lecture-4.pptxLecture-4.pptx
Lecture-4.pptx
 
Tables
TablesTables
Tables
 
Web I - 03 - Tables
Web I - 03 - TablesWeb I - 03 - Tables
Web I - 03 - Tables
 
HTML: Tables and Forms
HTML: Tables and FormsHTML: Tables and Forms
HTML: Tables and Forms
 
Handout5 tables
Handout5 tablesHandout5 tables
Handout5 tables
 
Table structure introduction
Table structure introductionTable structure introduction
Table structure introduction
 
v4-html-table-210321161424.pptx
v4-html-table-210321161424.pptxv4-html-table-210321161424.pptx
v4-html-table-210321161424.pptx
 
Working With Tables in HTML
Working With Tables in HTMLWorking With Tables in HTML
Working With Tables in HTML
 
html-table
html-tablehtml-table
html-table
 
Computer language - Html tables
Computer language - Html tablesComputer language - Html tables
Computer language - Html tables
 
HTML Tables
HTML TablesHTML Tables
HTML Tables
 
Html web designing using tables
Html web designing using tablesHtml web designing using tables
Html web designing using tables
 
Html tables
Html tablesHtml tables
Html tables
 
Html_Day_Three(W3Schools)
Html_Day_Three(W3Schools)Html_Day_Three(W3Schools)
Html_Day_Three(W3Schools)
 
table html web programing
table  html  web programingtable  html  web programing
table html web programing
 
Lecture3
Lecture3Lecture3
Lecture3
 
Html table tags
Html table tagsHtml table tags
Html table tags
 
Table and Form HTML&CSS
Table and Form HTML&CSSTable and Form HTML&CSS
Table and Form HTML&CSS
 

Recently uploaded

test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
Arif0071
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
3ipehhoa
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
JungkooksNonexistent
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
JeyaPerumal1
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
laozhuseo02
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
3ipehhoa
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
natyesu
 
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptxLiving-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
TristanJasperRamos
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
Gal Baras
 
Output determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CCOutput determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CC
ShahulHameed54211
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
laozhuseo02
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
Himani415946
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
nirahealhty
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
Rogerio Filho
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Sanjeev Rampal
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
3ipehhoa
 

Recently uploaded (16)

test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
 
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptxLiving-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
 
Output determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CCOutput determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CC
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
 

HTML Tables.ppt

  • 2. Lecture Overview  Learn about the basics of tables  Create simple 2-dimensional tables  Format tables  Create tables with complex structures
  • 3. Introduction to Tables (1)  Tables are grids made up of rows and columns  The intersection of a row and column is called a cell  Tables can contain  Text  Additional markup  Other tables  Images  And just about anything else  Tables are block-level elements
  • 4. Introduction to Tables (2)  Much has changed about tables from HTML 4 to HTML 5  Use tables to render truly tabular data  Use CSS for presentation  In this regard, CSS has replaced some table functionality  I’ll use the new constructs in this lecture to support good habits
  • 5. Basic Table Tags  The <table> tag is the outermost tag and marks the table  The deprecated border attribute defines the width of the border surrounding the table  The <tr> tag appears inside the <table> tag and marks a table row  The <td> tag appears inside the <tr> tag and marks the table data (cell)
  • 6. Basic Table Tags (Example)  Create a table with a 2-pixel border <table border=“2”> <tr> <td>Column 1</td> <td>Column 2</td> </tr> <tr> <td>Data 1</td> <td>Data 2</td> </tr> </table>
  • 7. Basic Table Tags (Example)  Create a table with a 2-pixel border
  • 8. Tables (Captions and Headers)  The <caption> element appears as a child of a <table> and contains the table’s title  The caption appears just above the table itself  The <th> element is similar to the <tr> element but contains the table’s header  The header is typically emphasized
  • 9. Tables (Captions and Headers / Example) <table border="2"> <caption>Monthly Savings</caption> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> </table>
  • 10. Tables (Grouping)  The <thead>, <tfoot>, and <tbody> tags are used to group table parts  Header, footer, body  Note that <tfoot> MUST appear after <tbody>  It’s used for dynamic table scrolling, which most browsers do not yet support  These are also logical (semantic) rather than physical elements
  • 11. <table> (Attributes)  The border attribute defines the thickness of the table’s border  Value is measured in pixels  The cellpadding attribute defines the number of pixels from the cell wall to the cell content  The cellspacing attribute defines the number of pixels between cells  We typically do this with CSS but we have not discussed CSS yet
  • 13. Column and Cell Attributes  align – justify the text within the columns  left, right center  width – the width of the column  Use relative or absolute widths  width=“25%” - 25% of the table  width=“100px” - 100 pixels  valign – vertical alignment  Values: top, middle, bottom, baseline  Supported by tables too  See example
  • 14. <table> Columns  The <col> tag appears as a child of the <table> or <colgroup> tag and describes formatting for the entire column  It’s often easier than formatting individual rows or cells  The <colgroup> tag is used to apply formatting to several columns
  • 15. <table> Columns (Example)  Center the data in the first column and right justify the second column <table border="1"> <col align="center" /> <col align="right" /> . . .
  • 16. Cell Spanning  Some tables have cells that should span multiple rows and columns  rowSpan attribute is used to create a cell that spans multiple rows  colspan attribute is used to create a cell that spans multiple columns
  • 18. Tables within Tables  That said, tables can contain tables, which can contain tables.  The process can get very complicated
  • 19. Table Formatting and CSS  We have not discussed CSS yet but I want to mention it here  Everything is a box in the eyes of CSS  A table is a box  A table row is a box  A table cell is a box  A nested table is just another box
  • 20. Table Formatting and CSS  Borderstyle is used to set the border of a cell, row or the table  All margin and padding works as you would expect
  • 21. Table Formatting (Conflicts)  Cell formatting overrides row formatting  Row formatting overrides table formatting  See the chapter’s example
  • 22. // 21