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!
Rechercher
Sellect from all Catégories 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
- Téléphone
- Music
- Accounting
- Causes
- Networking
Lire la suite
Comprehensive Guide to PHP Elements
1. Introduction to PHP
PHP (Hypertext...
What we mean by Server-side programming
Server-side programming refers to the...
How to Develop Leadership Skills for Success
Leadership is an essential skill that...
How to Built a wealthy mindset
A wealthy mindset starts with the right...
Meaning of Cloud computing
Cloud computing refers to the delivery of...