HTML / HTML Tables

Creating a Basic HTML Table

This tutorial covers the basics of creating a table in HTML. You'll learn how to use the <table>, <tr>, and <td> tags to create a simple table.

Tutorial 1 of 5 5 resources in this section

Section overview

5 resources

Covers the creation and styling of tables in HTML.

1. Introduction

In this tutorial, we will be learning about how to create a basic HTML table. The goal is to understand how HTML tables work and how we can create them.

By the end of this tutorial, you will learn:
- The significance and usage of the <table>, <tr>, and <td> HTML tags
- How to create a simple HTML table

Prerequisites for this tutorial include:
- Basic understanding of HTML
- Familiarity with HTML tags

2. Step-by-Step Guide

HTML tables are created using a combination of the following tags:
- <table>: This is the container tag used to define a table
- <tr>: This tag stands for table row and is used to define a row in the table
- <td>: This tag stands for table data and is used to define a cell in the table

Here's a simple example of how these tags are used to create a table:

<table>
    <tr>
        <td>Cell 1</td>
        <td>Cell 2</td>
    </tr>
    <tr>
        <td>Cell 3</td>
        <td>Cell 4</td>
    </tr>
</table>

This code will create a table with 2 rows and 2 columns.

Best practices and tips:
- Always close your HTML tags to prevent unexpected results
- Use indentation to make your code easier to read and understand

3. Code Examples

Example 1:

Let's create a simple table with 2 rows and 2 columns:

<table>
    <!-- Row 1 -->
    <tr>
        <td>Row 1, Column 1</td>
        <td>Row 1, Column 2</td>
    </tr>
    <!-- Row 2 -->
    <tr>
        <td>Row 2, Column 1</td>
        <td>Row 2, Column 2</td>
    </tr>
</table>

In this example, we have 2 <tr> tags, each representing a row, and each row has 2 <td> tags, each representing a cell in that row.

The output will be a simple table with 2 rows and 2 columns.

Example 2:

<table>
    <!-- Headers -->
    <tr>
        <th>Name</th>
        <th>Age</th>
        <th>Location</th>
    </tr>
    <!-- Row 1 -->
    <tr>
        <td>John Doe</td>
        <td>27</td>
        <td>New York</td>
    </tr>
    <!-- Row 2 -->
    <tr>
        <td>Jane Doe</td>
        <td>25</td>
        <td>Los Angeles</td>
    </tr>
</table>

In this example, we use the <th> tag, which stands for table header, to create a header row for our table.

4. Summary

In this tutorial, we've learned:
- The purpose and usage of the <table>, <tr>, and <td> HTML tags
- How to create a simple HTML table

To continue learning, you can explore more complex table structures and additional table-related tags, such as <thead>, <tbody>, and <tfoot>.

5. Practice Exercises

Practice makes perfect. Try out these exercises to reinforce what you've learned:
1. Create a table with 3 rows and 3 columns
2. Create a table with headers and at least 2 rows of data
3. Create a table with nested tables (a table inside a table)

Remember to always close your tags and use indentation for better readability.

Keep practicing and exploring. Happy coding!

Need Help Implementing This?

We build custom systems, plugins, and scalable infrastructure.

Discuss Your Project

Related topics

Keep learning with adjacent tracks.

View category

CSS

Master CSS to style and format web pages effectively.

Explore

JavaScript

Learn JavaScript to add interactivity and dynamic behavior to web pages.

Explore

Python

Explore Python for web development, data analysis, and automation.

Explore

SQL

Learn SQL to manage and query relational databases.

Explore

PHP

Master PHP to build dynamic and secure web applications.

Explore

Popular tools

Helpful utilities for quick tasks.

Browse tools

Interest/EMI Calculator

Calculate interest and EMI for loans and investments.

Use tool

Time Zone Converter

Convert time between different time zones.

Use tool

Meta Tag Analyzer

Analyze and generate meta tags for SEO.

Use tool

Random Name Generator

Generate realistic names with customizable options.

Use tool

CSV to JSON Converter

Convert CSV files to JSON format and vice versa.

Use tool

Latest articles

Fresh insights from the CodiWiki team.

Visit blog

AI in Drug Discovery: Accelerating Medical Breakthroughs

In the rapidly evolving landscape of healthcare and pharmaceuticals, Artificial Intelligence (AI) in drug dis…

Read article

AI in Retail: Personalized Shopping and Inventory Management

In the rapidly evolving retail landscape, the integration of Artificial Intelligence (AI) is revolutionizing …

Read article

AI in Public Safety: Predictive Policing and Crime Prevention

In the realm of public safety, the integration of Artificial Intelligence (AI) stands as a beacon of innovati…

Read article

AI in Mental Health: Assisting with Therapy and Diagnostics

In the realm of mental health, the integration of Artificial Intelligence (AI) stands as a beacon of hope and…

Read article

AI in Legal Compliance: Ensuring Regulatory Adherence

In an era where technology continually reshapes the boundaries of industries, Artificial Intelligence (AI) in…

Read article

Need help implementing this?

Get senior engineering support to ship it cleanly and on time.

Get Implementation Help