How to create a table by using HTML5 ?
An HTML table is defined using the “table” tag in the HTML page. Each table row is defined with the “tr” tag. A table header is defined with the “th” tag. By default, table headings are bold and centered. A table data or cell is defined with the “td” tag.
Syntax:
<table> Contents... </table>
Example:
html
<!DOCTYPE html>
< html >
< head >
< style >
body {
text-align: center;
}
h1 {
color: green;
}
th {
color: blue;
}
table,
tbody,
td {
border: 1px solid black;
border-collapse: collapse;
}
</ style >
</ head >
< body >
< center >
< h1 >GeeksforGeeks</ h1 >
< h2 >
HTML5: How to define a table?
</ h2 >
< table >
< thead >
< tr >
< th >Name</ th >
< th >User Id</ th >
</ tr >
</ thead >
< tbody >
< tr >
< td >Shashank</ td >
< td >@shashankla</ td >
</ tr >
< tr >
< td >GeeksforGeeks</ td >
< td >@geeks</ td >
</ tr >
</ tbody >
</ table >
</ center >
</ body >
</ html >
|
Output:
Supported browsers:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Last Updated :
23 Sep, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...