Align text in a table header

后端 未结 8 2147
生来不讨喜
生来不讨喜 2021-02-06 20:37

It seems align is not working for the th element. Here is my HTML:

8条回答
  •  离开以前
    2021-02-06 20:46

    Try:

    text-align: center;
    

    You may be familiar with the HTML align attribute (which has been discontinued as of HTML 5). The align attribute could be used with tags such as

    , 
    , and

    to specify the alignment of these elements. This attribute allowed you to align elements horizontally. HTML also has/had a valign attribute for aligning elements vertically. This has also been discontinued from HTML5.

    These attributes were discontinued in favor of using CSS to set the alignment of HTML elements.

    There isn't actually a CSS align or CSS valign property. Instead, CSS has the text-align which applies to inline content of block-level elements, and vertical-align property which applies to inline level and table cells.

    提交回复
    热议问题