Can HTML table have variable number of cells on rows?

后端 未结 5 766
情歌与酒
情歌与酒 2020-12-10 11:34

Or should the total amount of cells equal to columns * rows?

A table with different amount of cells on different rows seems to pass the W3 Validator.

5条回答
  •  死守一世寂寞
    2020-12-10 12:15

    Yes, you can make an HTML table and leave out elements on some of the rows, but this is considered bad form because you can't be sure how the HTML renderer (browser) will handle this situation. It may be rendered slightly differently by different browsers.

    The recommended way to define a table with a varying number of cells displayed per row is to use colspan to join two or more adjacent cells into one. This will keep the right-most cells lined up with their correct columns and eliminates any ambiguity about what you want the HTML renderer to do.

提交回复
热议问题