HTML – Tables

HTML Table: Tables are used to represent the record type information.

  • We create the table using <table> tag.
  • <tr> represents table-row
  • <td> represents table-column or data
  • <th> is used to define headings.

Note: It is recommended to display the table with borders.

Display Simple table with Borders:

<html>
            <head>
                        <title> Display table </title>
            </head>
            <body>
                        <table border=”1″>
                                    <tr>
                                                <td> One </td>
                                                <td> Two </td>
                                    </tr>
                                    <tr>
                                                <td> Three </td>
                                                <td> Four </td>
                                    </tr>
                        </table>
            </body>
</html>

Display centered table with caption:

<html>
            <head>
                        <title> Display table </title>
            </head>
            <body>
                        <table border=”1″ align=”center”>
                                    <caption> Numbers </caption>
                                    <tr>
                                                <td> One </td>
                                                <td> Two </td>
                                                <td> Three </td>
                                    </tr>
                                    <tr>
                                                <td> Four </td>
                                                <td> Five </td>
                                                <td> Six </td>
                                    </tr>
                        </table>
            </body>
</html>

Displaying Full Stack Coursed Information with Headings:

<html>
            <head> <title>FullStack Courses</title> </head>
            <body>
                        <table border=1>
                                    <tr>
                                                <th>Course</th>
                                                <th>Fees</th>
                                                <th>Duration</th>
                                    </tr>
                                    <tr>
                                                <td>UI</td>
                                                <td>25000</td>
                                                <td>3 Months</td>
                                    </tr>
                                    <tr>
                                                <td>Java</td>
                                                <td>30000</td>
                                                <td>4 Months</td>
                                    </tr>
                                    <tr>
                                                <td>Python</td>
                                                <td>25000</td>
                                                <td>3 Months</td>
                                    </tr>
                        </table>
            </body
</html>
Scroll to Top