HTML table <table> tag usage and attributes

As one of the commonly used tags, the form is very useful, and the unexpected things that you can see everywhere may be done by the form.

Tags:
<table> :define table, put it on the outer layer, wrap <tr><td>...;
<tr>(table row):define table row;
<td>(table data):define table cell;
<th>(table head):define table header;

Basic example
code:

<table>
    <tr>
        <td>(1,1)</td>
        <td>(1,2)</td>
    </tr>
    <tr>
        <td>(2,1)</td>
        <td>(2,2)</td>
    </tr>
</table>

display:

(1,1) (1,2)
(2,1) (2,2)

Code:

<table>
    <tr>
        <th>title1</th>
        <th>title2</th>
    </tr>
    <tr>
        <td>(2,1)</td>
        <td>(2,2)</td>
    </tr>
    <tr>
        <td>(3,1)</td>
        <td>(3,2)</td>
    </tr>
</table>

display:

title1 title2
(2,1) (2,2)
(3,1) (3,2)

Table common attributes:

width Set table width
height Set table height
border Set the border width of the table
align Set the horizontal alignment of the table on the web page
bgcolor Set the overall background color of the table

Common attributes of td/th:

width Set the width of the cell
height Set the height of the cell
align Set the horizontal alignment of the content in the cell
valign Set the vertical alignment of the content in the cell
rowspan Set the number of cells to be merged across rows (vertical)
colspan Set the number of cells to be merged across columns (horizontal)

Welcome to make mistakes, add, and continue to update~

Guess you like

Origin blog.csdn.net/z18223345669/article/details/109273086