是html< COL align>弃用? [英] Is html <COL align> deprecated?

查看:104
本文介绍了是html< COL align>弃用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看

  • W3Schools:HTML < col> 标签 HTML 4.01 - col 元素
  • >

    解决方案

    是的, align code>< col /> 不再出现在HTML5中。 说规范!
    $ b

    另外,值得注意的是,在< col /> 标签。 样式属性(或者从 id class 等)只考虑理性适用于色谱柱本身的特性。也就是说,虽然每个< td /> 可以包含文本内容,因此可以具有像 text-align 设置,< col /> 元素不包含文本,因此不适用任何文本级别样式。 (块级别的东西像 background-color 仍然有效。)



    然而,在不涉及 colspan rowspan ,您可以选择< td /> :nth-​​of-type 来在c> s(从而在某种意义上是列)。例如。使用

     表格将表的第三列居中放置在 c3  .c3 td:nth-​​type(3){text-align:center; } 






    strong>



    HTML标准
    $ b


    15过时的功能

    15.2不符合的功能
    p>

    以下属性已过时(尽管元素仍是该语言的一部分),并且不得由作者使用:
    ...

    对齐 col 元素

    $ ...

       使用CSS代替。

    WHATWG wiki为各种过时的呈现属性提供了一些推荐的备选方案:


     属性CS S当量
    ===================== ======================= ==============
    在适当的td / th


    i'm looking at the W3Schools demo of using the <COL> element to align columns:

    <table width="100%" border="1">
      <col align="left" />
      <col align="left" />
      <col align="right" />
      <tr>
        <th>ISBN</th>
        <th>Title</th>
        <th>Price</th>
      </tr>
      <tr>
        <td>3476896</td>
        <td>My first HTML</td>
        <td>$53</td>
      </tr>
    </table>
    

    And browser's rendering of it is not encouraging:

    Chrome (10.0.648.127):

    FireFox (3.6.8):

    Internet Explorer 9 (standards mode):

    Internet Explorer 8 (standards mode):

    Internet Explorer 7 (standards mode):

    Internet Explorer (quirks mode):

    It's interesting to note that <COL align> used to work in browsers, and the feature was taken away in ie8. (And Chrome, with position of being the arbiter of all things perfect, doesn't support it.)

    This makes me wonder if <COL align> is something that's not supposed to work.

    Has <COL align> been deprecated?


    Update One

    i understand that it hasn't been formally deprecated. But the fact that browsers used to support it, then stopped supporting it makes me believe that there is some historical story that i'm missing. i assume the intentional removal of col align support from IE, and the continued lack of support from other browsers, indicates something is going on.

    Update Two

    i was mistakenly assuming lack of support for all features of <COL> meant <COL> itself isn't supported. i mistakenly assumed that since the only attribute i was trying wasn't working: that the element wasn't working. This was my mistake; and in hindsight i should have asked if "COL align" is deprecated (which it is).

    In my defense i assumed an example would have been shown what wasn't working "anymore".

    See also

    解决方案

    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
    

    这篇关于是html&lt; COL align&gt;弃用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆