Why does table-caption increase the height of the table?

前端 未结 2 1124
不思量自难忘°
不思量自难忘° 2021-01-19 00:16

Both tables have their height set to 50px and their content is not overflowing. But the table with a caption is actually 70px, because the caption does not appear to be incl

2条回答
  •  情歌与酒
    2021-01-19 00:44

    That's explained in 17.4 Tables in the visual formatting model

    the table generates a principal block box called the table wrapper box that contains the table box itself and any caption boxes

    That is, when you set height: 50px on the element with display: table, it applies to the the table box itself, which does not include the caption.

    The table wrapper box does include it, therefore its height is the height of the table box itself (50px) plus the height of the caption (20px), that is, 70px.

提交回复
热议问题