0% found this document useful (0 votes)
7 views3 pages

Tables in HTML

The document provides instructions on creating tables in HTML using the <table>, <tr>, <td>, and <th> tags. It includes examples of a basic table, adding borders, and using colspan and rowspan to merge cells. Additionally, it offers tips for organizing tables and emphasizes using CSS for layout instead of complex tables.

Uploaded by

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

Tables in HTML

The document provides instructions on creating tables in HTML using the <table>, <tr>, <td>, and <th> tags. It includes examples of a basic table, adding borders, and using colspan and rowspan to merge cells. Additionally, it offers tips for organizing tables and emphasizes using CSS for layout instead of complex tables.

Uploaded by

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

Tables in HTML

Creating Tables

Use the <table> tag to create tables. Inside a table, use:

• <tr> for table rows


• <td> for table data (cells)
• <th> for table headers

Basic Table Example

<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Alice</td>
<td>24</td>
</tr>
<tr>
<td>Bob</td>
<td>30</td>
</tr>
</table>

This will display:


Name Age

Alice 24

Bob 30

Adding Borders

By default, tables have no border. Use the border attribute to add one.

<table border="1">
...
</table>

Table Headings vs Data

• <th> is usually bold and centered.


• <td> is regular table data.

Spanning Columns and Rows

Use colspan and rowspan to merge cells.

Column Span Example:

<tr>
<th colspan="2">Employee Details</th>
</tr>
Row Span Example:

<tr>
<td rowspan="2">John</td>
<td>Manager</td>
</tr>
<tr>
<td>IT Department</td>
</tr>

Tip

• Keep your tables organized and easy to read.


• Use headers ( <th> ) for important rows or columns.
• Avoid very complex tables for layout—use CSS for page design.

You might also like