Home > Article > Web Front-end > Basic learning tutorial on table tag in HTML
Using the table tag to display table content on the Web is one of the most basic functions of HTML. Here we will take a look at the basic learning tutorial of the table tag in HTML. Friends who need it can refer to it
The tag composition of the table
The table in HTML consists of
tag is used to define the columns of the table. The | tag is also a subclass of the | |
tags to separate the columns and form a Complete form. The tag combination relationship of the table is: <table> <tr> <td>我是单元格1</td> <td>我是单元格2</td> </tr> </table> Any html tags such as text, pictures, lists, paragraphs, forms, horizontal lines, etc. can be inserted into the table, and can even be used for page layout . However, the table layout has problems such as too long code redundancy, non-compliance with HTML specifications, and unfriendly search engines. Therefore, it is recommended that you try not to use tables for page layout unless a table is really needed on the page. |
, , |
---|
tag. The | tag of the table header is the same as the | |
---|---|---|
tag will be automatically bolded. Merge of cells The merging of cells is divided into vertical merging and horizontal merging. When merging, you need to determine whether there are corresponding numbers of cells in other rows and columns. Horizontally merge cells using the colspan attribute, whose value is a number that determines the number of cells to be merged. For example, colspan="2" means merging two cells to the right. Vertical merging of cells uses the rowspan attribute, which is the same as the horizontal merging attribute. It also determines the number of cells to be merged in numerical form. For example, rowspan="2" means merging two cells downward. Example demonstration code: <table border=“1”> <tr> <th>姓名</th> <th colspan=“2”>电话</th> </tr> <tr> <td>Bill Gates</td> <td>555 77 854</td> <td>555 77 855</td> </tr> </table><h4>横跨两行的单元格:</h4> <table border=“1”> <tr> <th>姓名</th> <td>Bill Gates</td> </tr> <tr> <th rowspan=“2”>电话</th> <td>555 77 854</td> </tr> <tr> <td>555 77 855</td> </tr> </table> Example demonstration effect: cell Margin
|