HTML Table

HTML Table

Published by: Anil K. Panta

HTML Tables

Tables are defined with the <table> tag. A table is divided into rows (with the <tr> tag), and each row is divided into data cells (with the <td> tag). The letters td stands for "table data," which is the content of a data cell. A data cell can contain text, images, lists, paragraphs, forms, horizontal rules, tables, etc. For example, 



Output:

row 1, cell 1

row 1, cell 2

row 2, cell 1

row 2, cell 2


We use border attribute to display table with border as shown in the above example. Headings in a table are defined with <th> tag. For example,



Output:

Heading

Another Heading

row 1, cell 1

row 1, cell 2

row 2, cell 1

row 2, cell 2


We can use <caption> tag inside a <table> to display a caption for a table. We can define table cells that span more than one row or one column using colspan and rowspan attributes respectively. For example, 



We can use cellpadding and cellspacing attributes to create white space between the cell content and its borders, and to increase the distance between cells respectively. For example,



We can use align attribute to align the contents of a cell. For example,


We will get back to you via email or phone call