Is html deprecated?

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

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

7条回答
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

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 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

can contain text content and thus can have attributes like text-align set, the
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

提交回复
热议问题