0% found this document useful (0 votes)
36 views

Defining Tables in HTML

Tables are used to organize and present data in a grid format. HTML uses <table>, <tr>, <th>, and <td> tags to structure tables, with <table> for the table, <tr> for rows, <th> for header cells, and <td> for regular data cells. CSS can be used to style tables by adding borders and collapsing borders to touch.

Uploaded by

Abhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Defining Tables in HTML

Tables are used to organize and present data in a grid format. HTML uses <table>, <tr>, <th>, and <td> tags to structure tables, with <table> for the table, <tr> for rows, <th> for header cells, and <td> for regular data cells. CSS can be used to style tables by adding borders and collapsing borders to touch.

Uploaded by

Abhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

HTML | Tables

A table is an arrangement of data in rows and columns, or possibly in a more complex


structure. Tables are widely used in communication, research, and data analysis.
 Tables are useful for various tasks such as presenting text information and numerical
data.
 Tables can be used to compare two or more items in tabular form layout.
 Tables are used to create databases.

Defining Tables in HTML


An HTML table is defined with the “table” tag. 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/cell is defined with the “td” tag.

<!DOCTYPE html>

<html>

<body>

<table style="width:100%">

<tr>

<th>Firstname</th>

<th>Lastname</th>

<th>Age</th>

</tr>

<tr>

<td>Priya</td>

<td>Sharma</td>

<td>24</td>

</tr>

<tr>

<td>Arun</td>

<td>Singh</td>

<td>32</td>

</tr>
<tr>

<td>Sam</td>

<td>Watson</td>

<td>41</td>

</tr>

</table>

</body>

</html>

1.Adding a border to a HTML Table: A border is set using the CSS border property. If you
do not specify a border for the table, it will be displayed without borders.

<!DOCTYPE html>

<html>

<head>

<style>

table, th, td {

border: 1px solid black;

</style>

</head>

<body>

<table style="width:100%">

<tr>

<th>Firstname</th>

<th>Lastname</th>

<th>Age</th>

</tr>
<tr>

<td>Priya</td>

<td>Sharma</td>

<td>24</td>

</tr>

<tr>

<td>Arun</td>

<td>Singh</td>

<td>32</td>

</tr>

<tr>

<td>Sam</td>

<td>Watson</td>

<td>41</td>

</tr>

</table>

</body>

</html>

Adding Collapsed Borders in a HTML Table: For borders to collapse into one border, add
the CSS border-collapse property.

<!DOCTYPE html>

<html>

<head>

<style>

table, th, td {

border: 1px solid black;


border-collapse: collapse;

</style>

</head>

<body>

<table style="width:100%">

<tr>

<th>Firstname</th>

<th>Lastname</th>

<th>Age</th>

</tr>

<tr>

<td>Priya</td>

<td>Sharma</td>

<td>24</td>

</tr>

<tr>

<td>Arun</td>

<td>Singh</td>

<td>32</td>

</tr>

<tr>

<td>Sam</td>

<td>Watson</td>

<td>41</td>

</tr>

</table>

</body>
</html>

Day 7 8 9 10
Mocat

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy