HTML table tag

We can create a table in html by using <htmt></htmt> tag.
with in table tag we use <tr> to create new table row.
inside tr we use <td> tag to specify data value.
to provide table header <th> tag is used

One table can contain multiple table rows and each row can contain multiple table data.

Syntax

<th> is optional it is used to provide HTML Table with Header

Example

Sr NoNameCity
1ManishBhilai
1MohanBhopal
1RamBanglore

For providing data heading we use <th> tag

HTML Table with border

In above table we have not provided table border to provide HTML table with border we can use border attribute with border tag as below

table border=" 1|0"

0 specify no border around the table
1 specify border around the table

HTML Border attribute in not support by HTML 5.

Insted of border attribute use CSS.

User NameMailid
Ram[email protected]
Mohan[email protected]
Shyam[email protected]

HTML Table border with CSS

HTML Table With Caption

To provide table caption <caption> tag is used is should be used below the <table> tag

User Name and Mailid details of user
User NameMailid
Ram[email protected]
Mohan[email protected]
Shyam[email protected]

HTML Table Grouping Tag

<thead>, <tbody> and <tfooter> tags are used for grouping table rows <thead> is used to group table header


<tbody> is used to group table body
<tfooter is used to group table footer

Q Which tag allows you to add a row in a table?

tr rag allows us to add a row in a table

Q Can a data cell contain images in html

yes We can include images in HTML data cell

Q what is the use of “border ” attribute of table tag?

“border ” attribute of table tag is used to set table border