Is html deprecated?

前端 未结 7 857
清酒与你
清酒与你 2021-01-01 12:45

i\'m looking at the W3Schools demo of using the element to align columns:

相关标签:
7条回答
  • 2021-01-01 13:04

    According to the second example table in the HTML spec, it’s colgroup, despite the lack of colgroup tags.

    http://www.w3.org/TR/html4/struct/tables.html#h-11.4.1

    0 讨论(0)
  • 2021-01-01 13:09

    In the interest of making the markup semantically meaningful have you considered substituting your <col> tags with <colgroup>?

    <col> is purely used for styling whereas <colgroup> can be used to group related columns (Perhaps this is why you intend to align two of them left?) You can then apply CSS to the various colgroups to style them accordingly.

    0 讨论(0)
  • 2021-01-01 13:11

    The <col> tag is not deprecated.

    See: How to use <col> tag correctly and is it supported in all browser? I think this answer clarifies its usage, and explains some of the trouble you are having with it.

    It is part of XHTML and HTML 5. http://www.tutorialspoint.com/html5/html5_tags.htm

    0 讨论(0)
  • [edit] Uggh, you changed your question to refer specifically to the align property.

    No, it hasn't been deprecated. Browser support is there but the implementation and extent are varied. The only cross-browser success I've really had in using it has been with setting widths for entire columns.

    Notes from W3:

    • Firefox, Chrome, and Safari only support the span and width attributes of the colgroup element.
    • Only the width attribute [of the col element] works in Firefox (none of the other attributes).
    0 讨论(0)
  • 2021-01-01 13:12

    No it has not, it is both part of the html4 spec and the html5 spec.

    http://www.w3.org/TR/html401/struct/tables.html#h-11.2.4.2

    http://dev.w3.org/html5/markup/col.html

    http://www.html-5.com/tags/col-tag/

    0 讨论(0)
  • 2021-01-01 13:15

    Yes, the align attribute of <col /> no longer appears in HTML5. Says the spec!

    Also, it's worth noting that you can't achieve a similar result using CSS on the <col /> tag. The style attribute (or induced style from id, class, etc.) only takes into account properties that sensibly apply to the column itself. That is, while each <td /> can contain text content and thus can have attributes like text-align set, the <col /> element does not contain text and thus none of the text-level styles apply. (Block-level stuff like background-color still works.)

    However, in basic cases not involving colspan or rowspan, you can select blocks of <td />s (and thus "columns" in a sense) by using the CSS pseudo-class :nth-of-type. E.g. to center the third column of the table with class c3 use

    table.c3 td:nth-of-type(3) { text-align: center; }
    

    Edit by OP:

    From The HTML Standard:

    15 Obsolete features
    15.2 Non-conforming features

    The following attributes are obsolete (though the elements are still part of the language), and must not be used by authors: ...
    align on col elements
    ...

       Use CSS instead.

    The WHATWG wiki gives some recommended alternatives for various obsolete presentational attributes:

    Attribute              CSS equivalent
    =====================  =====================================
    align on col elements  'text-align' on the appropriate td/th
    
    0 讨论(0)
提交回复
热议问题