25
Topic 06 : HTML Tables Er. Pradip Kharbuja

Topic 06 : HTML Tables

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Topic 06 : HTML Tables

Topic 06 : HTML Tables

Er. Pradip Kharbuja

Page 2: Topic 06 : HTML Tables

Table Structure

▪ HTML elements can be used to describe tabular data

▪ The <table> element defines the start and end of the table

▪ The <tr> element defines the start and end of a row in the table

▪ The <td> element defines a table cell

Page 3: Topic 06 : HTML Tables

Write the HTML Table Code

Page 4: Topic 06 : HTML Tables

HTML Table Code

Page 5: Topic 06 : HTML Tables

The colspan Attribute

▪ The colspan attribute merges two or more columns into one column.

Page 6: Topic 06 : HTML Tables

The rowspan Attribute

▪ The rowspan attribute merges two or more rows into one row.

Page 7: Topic 06 : HTML Tables

Write HTML Code

Page 8: Topic 06 : HTML Tables

The <thead>,<tfoot> & <tbody> Elements

▪ We can specify rows as being part of the table header, the table body or the table footer.

▪ The <thead>, <tfoot> and <tbody> allow us to add extra meaning to the table contents.

Page 9: Topic 06 : HTML Tables

The <thead>,<tfoot> & <tbody> Elements

▪ The <tfoot> element should be added before the <tbody>.

▪ Tables are perfectly valid without the use of these elements, so for the simplicity, they are often ommited.

Page 10: Topic 06 : HTML Tables

Accessible Tables

▪ Screen readers linearize tables.

– Read out the contents in order

– From left to right, top to bottom

▪ In this example, the screen reader would read

– S.N., Item, Price, Qty, Amount, 1, Book, 200, 5, 1000

Page 11: Topic 06 : HTML Tables

Accessible Tables

▪ There are a number of HTML features which can be used to enhance the accessibility of tables.

1. The summary attribute

2. The <caption> element

3. The <th> element

Page 12: Topic 06 : HTML Tables

The summary attribute

▪ The summary attribute can be read out by screen readers.

▪ It should describe the structure of the table, which can help the user make sense of the table data when it is linearised.

Page 13: Topic 06 : HTML Tables

The <caption> Element

▪ The caption element provides a title for the table.

Page 14: Topic 06 : HTML Tables

The <th> Element

▪ The <th> element specifies that the cell contains table header information.– Distinguishes the headers from data

▪ <th> elements are usually displayed in bold and center.

Page 15: Topic 06 : HTML Tables

Table and CSS

Page 16: Topic 06 : HTML Tables

Table and CSS

Page 17: Topic 06 : HTML Tables

Table and CSS

▪ The border-collapse property is specific to tables.

– Specifies if the cell borders are merged

– The default value is separate.

Page 18: Topic 06 : HTML Tables

Table and CSS

Page 19: Topic 06 : HTML Tables

Highlighting Specific Cells

▪ We can style individual cells, rows and columns using class and id attributes.– The <col> and <colgroup> elements allow

us to target columns.

Page 20: Topic 06 : HTML Tables

The <colgroup> and <col> Elements

▪ The <col> and <colgroup> elements allow us to describe specific columns.

Page 21: Topic 06 : HTML Tables

Using Tables for Page Layout

▪ Before widespread browser support for CSS, tables were often used for page layout.

▪ With borders not visible, the table acts as a grid setting out the page contents.

▪ The following slide is a screen shot of the Amazon website from August 2004.

▪ Tables are used to design the page.

▪ Amazon now have a CSS driven design.

Page 22: Topic 06 : HTML Tables

Using Tables for Page Layout

http://www.amazon.com/

Amazon - August 2004

Page 23: Topic 06 : HTML Tables

Using Tables for Page Layout

▪ The red lines show the table borders.

– Complex tables

– Tables inside tables - nested tables

http://www.amazon.com/

Page 24: Topic 06 : HTML Tables

Tables and Mobile Devices

▪ Tables do not work well on small screen sizes.

– User has to scroll horizontally to view contents

▪ Displaying complex tables can be computationally intensive.

– Mobile devices have limited processing power

Page 25: Topic 06 : HTML Tables

End of Topic 6

Topic 6 : HTML Tables