table 个单元格的垂直对齐默认值
Default value of vertical-align for table cells
根据spec,vertical-align
的默认值是baseline
。
Align the baseline of the box with the baseline of the parent box. If
the box does not have a baseline, align the bottom margin edge with
the parent's baseline.
但是,当涉及到 table 个单元格 (td
) 时,默认值似乎总是 middle
。
Align the vertical midpoint of the box with the baseline of the parent
box plus half the x-height of the parent.
我希望官方确认此行为,但我在 W3C 文档中找不到任何内容。我发现的所有内容都表示默认值为 baseline
.
哪里说 vertical-align
的默认值是 table 个单元格的 middle
?
如规范所述,vertical-align
的初始值始终为 baseline
:
vertical-align
- Initial: baseline
但是,如 The cascade、
中所述
Conforming user agents must apply a default style sheet (or
behave as if they did).
A user agent's default style sheet should present the elements of the
document language in ways that satisfy general presentation
expectations for the document language.
See A sample style sheet for HTML for a recommended default style
sheet for HTML documents.
并且推荐的样式sheet包含
thead, tbody,
tfoot { vertical-align: middle }
td, th, tr { vertical-align: inherit }
因此,如果您(作者来源)没有为 tbody
和 td
的 vertical-align
提供任何值,级联将检索 middle
来自用户代理来源的值。
请注意,默认样式 sheet 取决于实现,因此某些浏览器可能会为不同的元素设置不同的 vertical-align
值。
根据spec,vertical-align
的默认值是baseline
。
Align the baseline of the box with the baseline of the parent box. If the box does not have a baseline, align the bottom margin edge with the parent's baseline.
但是,当涉及到 table 个单元格 (td
) 时,默认值似乎总是 middle
。
Align the vertical midpoint of the box with the baseline of the parent box plus half the x-height of the parent.
我希望官方确认此行为,但我在 W3C 文档中找不到任何内容。我发现的所有内容都表示默认值为 baseline
.
哪里说 vertical-align
的默认值是 table 个单元格的 middle
?
如规范所述,vertical-align
的初始值始终为 baseline
:
vertical-align
- Initial: baseline
但是,如 The cascade、
中所述Conforming user agents must apply a default style sheet (or behave as if they did).
A user agent's default style sheet should present the elements of the document language in ways that satisfy general presentation expectations for the document language.
See A sample style sheet for HTML for a recommended default style sheet for HTML documents.
并且推荐的样式sheet包含
thead, tbody,
tfoot { vertical-align: middle }
td, th, tr { vertical-align: inherit }
因此,如果您(作者来源)没有为 tbody
和 td
的 vertical-align
提供任何值,级联将检索 middle
来自用户代理来源的值。
请注意,默认样式 sheet 取决于实现,因此某些浏览器可能会为不同的元素设置不同的 vertical-align
值。