<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 or justify 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 the td:nth-child(an+b) CSS selector. Set a to zero and b 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 the char as the value of the text-align property Не реализовано.
  • 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. Для получения подобного эффекта, используй свойство CSS background-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 to char, 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 the char attribute as the value of the text-align property Не реализовано.

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

  • span
    • : This attribute contains a positive integer indicating the number of consecutive columns the <col> element spans. If not present, its default value is 1.
  • 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 as bottom.
      • 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 the td: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 the vertical-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.
  • 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 as 0.5* also can be used.

Пример

Please see the <table> (en-US) page for examples on <col>.

Спецификации

Specification
HTML Standard
# the-col-element

Совместимость с браузером

BCD tables only load in the browser

Смотрите также