Steps on how to create a table using HTML

Creating a table in HTML involves using the <table>
element along with other related elements like <tr>
for table rows, <th>
for table headers, and <td>
for table data cells. Here's an example of how to create a simple table:
Basic Structure
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Table Example</title>
<style>
table {
width: 50%;
border-collapse: collapse;
margin: 20px auto;
font-family: Arial, sans-serif;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: center;
}
th {
background-color: #f4f4f4;
}
</style>
</head>
<body>
<h1 style="text-align: center;">HTML Table Example</h1>
<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
<td>Row 1, Cell 3</td>
</tr>
<tr>
<td>Row 2, Cell 1</td>
<td>Row 2, Cell 2</td>
<td>Row 2, Cell 3</td>
</tr>
<tr>
<td>Row 3, Cell 1</td>
<td>Row 3, Cell 2</td>
<td>Row 3, Cell 3</td>
</tr>
</tbody>
</table>
</body>
</html>
Explanation
<table>
: The container for the entire table.<thead>
: Contains the table header rows.<th>
: Defines a header cell, typically bold and centered.<tbody>
: Contains the main content of the table.<tr>
: Defines a single row in the table.<td>
: Defines a single data cell.
Styling
You can style your table with CSS, as shown in the example. This includes adding borders, padding, and background colors for a cleaner look.
Let me know if you'd like additional features like merged cells, captions, or advanced styling!
Search
Sellect from all Categories bellow ⇓
- Artificial Intelligence (AI)
- Cybersecurity
- Blockchain & Cryptocurrencies
- Internet of Things
- Cloud Computing
- Big Data & Analytics
- Virtual Reality
- 5G & Future Connectivity
- Robotics & Automation
- Software Development & Programming
- Tech Hardware & Devices
- Tech in Healthcare
- Tech in Business
- Gaming Technologies
- Tech in Education
- Machine Learning (ML)
- Blogging
- Affiliate Marketing
- Make Money
- Digital Marketing
- Product Review
- Social Media
- Excel
- Graphics design
- Freelancing/Consulting
- FinTech (Financial Technology)
- E-commerce and Digital Marketing
- Business
- Sport
- Self Development
- Tips to Success
- Video Editing
- Photo Editing
- Website Promotion
- YouTube
- Lifestyle
- Health
- Computer
- Phone
- Music
- Accounting
- Causes
- Networking
Read More
How To Create a Responsive iFrame In HTML
Advanced usage of HTML <iframe> involves...
Content Marketing: How to Write Blogs That Drive Traffic
Content marketing is a powerful strategy for...
How Do Cryptocurrencies Work? A Step-by-Step Explanation
Here’s a detailed explanation of How...
Why Your Newport Business Deserves the Best SEO Agency
When you picture Newport, you might think of...
The Difference Between Black Hat, White Hat, and Gray Hat Hackers
Hackers are individuals who explore and...