Default value of vertical-align for table cells

前端 未结 1 1474
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-06 17:35

According to the spec, the default value of vertical-align is baseline.

baseline

Align the baseline of the box w

相关标签:
1条回答
  • 2020-12-06 18:23

    As said by the spec, the initial value of vertical-align is always baseline:

    vertical-align

    • Initial: baseline

    However, as explained in 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.

    And that recommended stylesheet contains

    thead, tbody,
    tfoot           { vertical-align: middle }
    td, th, tr      { vertical-align: inherit }
    

    Therefore, if you (author origin) don't provide any value for tbody's nor td's vertical-align, the cascade will retrieve the middle value from the user agent origin.

    Note the default style sheet is implementation dependent, so some browsers may set different vertical-align values for different elements.

    0 讨论(0)
提交回复
热议问题