Techoceanhub logo

Creating tables in HTML

To create tables in HTML, you can use the <table>, <tr>, <th>, and <td> tags. Here’s an example of how you can create a basic table:

<!DOCTYPE html>
<html>
<head>
    <title>Table Example</title>
</head>
<body>
    <table>
        <tr>
            <th>Header 1</th>
            <th>Header 2</th>
            <th>Header 3</th>
        </tr>
        <tr>
            <td>Data 1</td>
            <td>Data 2</td>
            <td>Data 3</td>
        </tr>
        <tr>
            <td>Data 4</td>
            <td>Data 5</td>
            <td>Data 6</td>
        </tr>
    </table>
</body>
</html>

In this example, we have a table with three columns and two rows. The <table> tag represents the entire table. Inside the table, we use the <tr> tag to define table rows. Each row contains cells represented by the <td> tags for regular data. For header cells, we use the <th> tag instead of <td>. By default, browsers render the contents of <th> with bold text.

You can add more rows or columns by duplicating the <tr> and <td> elements as needed. You can also use CSS to style the table, apply borders, set background colors, and modify other visual aspects to match your desired design.

Share:

Categories

Archives

Related Posts

Array Destructuring

Array Destructuring Array destructuring is a powerful syntax introduced in ES6 that allows you to unpack elements from an array

Read More »

Explore our Affiliated partner links

hostgator website plan

Hostgator

Best Website hosting plans & Best for 24/7 support.

hostinger webhosting plan

Hostinger

Reasonable website hosting packages for small business & 24/7 Email support

Elementor pro

Design Worpdress website quickly using Elementor Builder and AI

buy elementor website templates

Buy Elementor Website Template

Buy ready made Elementor Website Template from us & Get Free Elementor pro licence for 1 year .