<col>
HTML-элемент
<col>
определяет столбец в таблице и используется для определения общей семантики на всех ячейках. Обычно он находится в элементе <colgroup>
(en-US).
Этот элемент позволяет стилизировать столбцы с использованием CSS, но только несколько атрибутов будут иметь эффект на столбец (смотри спецификацию CSS 2.1).
Категория контента (en-US) | Нет |
---|---|
Допустимое содержимое | Нет, это пустой элемент. |
Пропуск тегов | Начальный тег обязательный, но, поскольку это элемент без контента, использование концевого тега запрещено. |
Допустимые родители | Только <colgroup> (en-US), хотя он может быть определён неявно, т. к. его стартовый тег не является обязательным. Тег <colgroup> (en-US) обязан не иметь атрибута span (en-US). |
Допустимые ARIA-роли | нет |
DOM-интерфейс | HTMLTableColElement (en-US) |
Атрибуты
Этот элемент включает общие атрибуты.
align
Устарело ,- : Этот перечисляемый атрибут указывает, как будет обрабатываться горизонтальное выравнивание контента каждой ячейки столбца. Возможные значения:
left
, выравнивает контент к левой стороне ячейкиcenter
, центрирует контент ячейкиright
, выравнивает контент к правой стороне ячейкиjustify
, вставляет пробелы в текстовый контент так, чтобы контент был выравнен по ширинеchar
, выравнивает текстовый контент по специальному символу с минимальным смещением, определяемым атрибутамиchar
иcharoff
Не реализовано (смотрите Firefox bug 2212).Если этот атрибут не установлен, его значение будет переопределено отalign
(en-US) элемента<colgroup>
(en-US), к которому этот элемент принадлежит. Если его также нет, предполагается значениеleft
.**Примечание:**Не используйте этот атрибут, поскольку он устарел (не поддерживается) в последнем стандарте. To achieve the same effect as the
left
,center
,right
orjustify
values:- Do not try to set the
text-align
property on a selector giving a<col>
element. Because<td>
elements are not descendant of the<col>
element, they won't inherit it. - If the table doesn't use a
colspan
attribute, use thetd:nth-child(an+b)
CSS selector. Seta
to zero andb
to the position of the column in the table, e.g.td:nth-child(2) { text-align: right; }
to right-align the second column. - If the table does use a
colspan
attribute, the effect can be achieved by combining adequate CSS attribute selectors like[colspan=n]
, though this is not trivial. - To achieve the same effect as the
char
value, in CSS3, you can use the value of thechar
as the value of thetext-align
property Не реализовано.
- Do not try to set the
- : Этот перечисляемый атрибут указывает, как будет обрабатываться горизонтальное выравнивание контента каждой ячейки столбца. Возможные значения:
bgcolor
Non-standard-
: Этот атрибут определяет цвет фона каждой ячейки столбца. Это один из 6-и значных кодов в шестнадцатеричной системе счисления, определённый как sRGB с префиксом '#'. Можно использовать одну из шестнадцати предопределённых строк: black
= "#000000"green
= "#008000"silver
= "#C0C0C0"lime
= "#00FF00"gray
= "#808080"olive
= "#808000"white
= "#FFFFFF"yellow
= "#FFFF00"maroon
= "#800000"navy
= "#000080"red
= "#FF0000"blue
= "#0000FF"purple
= "#800080"teal
= "#008080"fuchsia
= "#FF00FF"aqua
= "#00FFFF"> Примечание: Не используй этот атрибут, поскольку он нестандартный и реализован только в некоторых версиях Microsoft Internet Explorer: элемент <col>
должно быть стилизован с использованием CSS. Для получения подобного эффекта, используй свойство CSSbackground-color
, для соответствующих элементов<td>
.
-
char
Устарело ,- : This attribute is used to set the character to align the cells in a column on. Typical values for this include a period (.) when attempting to align numbers or monetary values. If
align
is not set tochar
, this attribute is ignored.Примечание: Do not use this attribute as it is obsolete (and not supported) in the latest standard. To achieve the same effect as the
char
, in CSS3, you can use the character set using thechar
attribute as the value of thetext-align
property Не реализовано.
- : This attribute is used to set the character to align the cells in a column on. Typical values for this include a period (.) when attempting to align numbers or monetary values. If
charoff
Устарело ,- : This attribute is used to indicate the number of characters to offset the column data from the alignment characters specified by the char attribute.
**Примечание:**Do not use this attribute as it is obsolete (and not supported) in the latest standard.
- : This attribute is used to indicate the number of characters to offset the column data from the alignment characters specified by the char attribute.
span
- : This attribute contains a positive integer indicating the number of consecutive columns the
<col>
element spans. If not present, its default value is1
.
- : This attribute contains a positive integer indicating the number of consecutive columns the
valign
Устарело ,- : This attribute specifies the vertical alignment of the text within each cell of the column. Possible values for this attribute are:
baseline
, which will put the text as close to the bottom of the cell as it is possible, but align it on the baseline of the characters instead of the bottom of them. If characters are all of the size, this has the same effect asbottom
.bottom
, which will put the text as close to the bottom of the cell as it is possible;middle
, which will center the text in the cell;- and
top
, which will put the text as close to the top of the cell as it is possible.**Примечание:**Do not use this attribute as it is obsolete (and not supported) in the latest standard:
- Do not try to set the
vertical-align
property on a selector giving a<col>
element. Because<td>
elements are not descendant of the<col>
element, they won't inherit it.
- If the table doesn't use a
colspan
attribute, use thetd:nth-child(an+b)
CSS selector where a is the total number of the columns in the table and b is the ordinal position of the column in the table. Only after this selector thevertical-align
property can be used. - If the table does use a
colspan
attribute, the effect can be achieved by combining adequate CSS attribute selectors like[colspan=n]
, though this is not trivial.
- Do not try to set the
- : This attribute specifies the vertical alignment of the text within each cell of the column. Possible values for this attribute are:
width
- : This attribute specifies a default width for each column in the current column group. In addition to the standard pixel and percentage values, this attribute might take the special form
0*
, which means that the width of each column in the group should be the minimum width necessary to hold the column's contents. Relative widths such as0.5*
also can be used.
- : This attribute specifies a default width for each column in the current column group. In addition to the standard pixel and percentage values, this attribute might take the special form
Пример
Please see the <table>
(en-US) page for examples on <col>
.
Спецификации
Specification |
---|
HTML Standard # the-col-element |
Совместимость с браузером
BCD tables only load in the browser
Смотрите также
- Other table-related HTML elements:
<caption>
,<colgroup>
(en-US),<table>
(en-US),<tbody>
(en-US),<td>
,<tfoot>
,<th>
(en-US),<thead>
(en-US),<tr>
(en-US); - CSS properties and pseudo-classes that may be specially useful to style the
<col>
element:- the
width
property to control the width of the column; - the
:nth-child
pseudo-class to set the alignment on the cells of the column; - the
text-align
property to align all cells content on the same character, like '.'.
- the