5️⃣

3.5 Tables

3.5 Tables

HTML tables allow web authors to arrange data into rows and columns.

Defining an HTML Table

An HTML table is defined with the<table>tag.

Each table row is defined with the <tr> tag. A table header is defined with the <th> tag. By default, table headings are bold and centered. A table data/cell is defined with the <td> tag.

Note: The <td> elements are the data containers of the table. They can contain all sorts of HTML elements; text, image, lists, other tables, etc.

HTML Table- Cells that Span Many Columns

To make a cell span more than one column, use the colspan attribute.

HTML Table- Cells that Span Many Rows

<!DOCTYPE html>

<html>
   <head>
        <meta charset="utf-8">
         <title>Tables</tilte>
    </head>
        
          <body>
              <table>
                 <tr><th>Name</th><th>Company</th><th>Dat of Birth</th></tr>
                  <tr><td>Mark Zuckerberg</td><td>Faceook</td><td>1984</td></tr>
                   <tr rowspan ="2"><td>Bill Gates</td><td>Microsoft</td><td>1955</td></tr>
                    <tr><td colspan="2">Steve Jobs</td><td>1955</td></tr>
                </table>
              </body>
           </html>

Previous Section

Next Section

⚖️

Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.