Table in HTML

Source: Internet
Author: User
HTML <Table> label definition and usage

<Table> tags define HTML tables.

A simple HTML table consists of a table element and one or more TR, Th, or TD elements.

The TR element defines the table row, the th element defines the header, and the TD element defines the table unit.

More complex HTML tables may also include caption, Col, colgroup, thead, tfoot, and tbody elements.

Table, TR, and TD. That's enough. Add a header to the regular vertex, that is, table, TR, Th, TD. If the title is included, use caption.

Table, thead, tbody, tfoot, TR, th, and TD are used together to group tables.

 

The use of Col and colgroup is more complicated.

 

HTML <Col> label definition and usage

<Col> labels define attribute values for one or more columns in a table.

To apply a style to all columns, the <Col> label is very useful, so you do not need to apply the style to each unit or row repeatedly.

You can only use the <Col> label in the table or colgroup element.

Instance

The Col element specifies the alignment for the three columns in the table:

<Table width = "100%" border = "1"><Col align = "Left"/><Col align = "Left"/><Col align = "right"/><Tr> <TH> ISBN </Th> <TH> title </Th> <TH> price </Th> </tr> <TD> 3476896 </ TD> <TD> my first HTML </TD> <TD> $53 </TD> </tr> </table>

 

 

HTML <colgroup> label definition and usage

<Colgroup> labels are used to combine columns in a table for formatting.

To apply a style to all columns, the <colgroup> label is very useful, so that you do not need to apply the style to each unit or row repeatedly.

<Colgroup> labels can only be used in table elements.

Instance

The two colgroup elements specify different alignment and style for the three columns in the table (note that the first colgroup element spans two columns ):

<Table width = "100%" border = "1"> <colgroup span = "2" align = "Left"> </colgroup> <colgroup align = "right" style =" color: # 0000ff; "> </colgroup> <tr> <TH> ISBN </Th> <TH> title </Th> <TH> price </Th> </tr> <tr> <TD> 3476896 </TD> <TD> my first HTML </TD> <TD> $53 </TD> </tr> </table>

 

We recommend that you use table, TR, and TD. Relatively simple. It is not prone to errors. In general, you can use table, thead, tbody, tfoot, TR, th, and TD.

In special cases, Col and colgroup are used.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.