Skip to Content

<col>

Width, alignment, and border settings for one column of a tabular layoutIn development

<col> is a Sectional component that sets the width, alignment, and borders of one column of a <tabular>. It holds no content of its own — the content still lives in the <row> and <cell> components — and it is written before the rows, one <col> per column, left to right.

Attributes and Properties

Attributes for <col>

Highlighted (4)

keyword. Border style for the trailing edge of this column: its right edge in a left-to-right document, its left edge in a right-to-left one.

ValueDescription
noneDo not render a border.
minorRender a thin border line.
mediumRender a medium-weight border line.
majorRender a thick border line.

keyword. Horizontal alignment for cells in this column.

ValueDescription
startAlign cell content to the leading edge: the left in a left-to-right document, the right in a right-to-left one.
centerCenter cell content horizontally.
endAlign cell content to the trailing edge: the right in a left-to-right document, the left in a right-to-left one.
justifyJustify cell content across the full cell width.

keyword. Border style for the top edge of this column.

ValueDescription
noneDo not render a border.
minorRender a thin border line.
mediumRender a medium-weight border line.
majorRender a thick border line.

componentSize. Display width of this column. Expressed as a percentage of the width of the tabular layout so that it survives conversion to PreTeXt.

Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. Default value: 1. The style number used to select this component's visual styling from the available style definitions.

Properties for <col name="c">

Highlighted (4)
$c.endBorder

text. Border style for the trailing edge of this column: its right edge in a left-to-right document, its left edge in a right-to-left one.

$c.halign

text. Horizontal alignment for cells in this column.

$c.topBorder

text. Border style for the top edge of this column.

$c.width

componentSize. Display width of this column. Expressed as a percentage of the width of the tabular layout so that it survives conversion to PreTeXt.

Other (4)
$c.disabled

boolean. Whether this component is disabled and cannot be interacted with.

$c.fixed

boolean. Whether this component's value is fixed and cannot be modified.

$c.fixLocation

boolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

$c.hidden

boolean. Whether this component is hidden from the rendered output.

Common to all components (4)
$c.doenetML

text. The DoenetML source code that produced this component.

$c.hide

boolean. Whether to hide this component from the rendered output.

$c.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$c.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Examples

Example: giving each column its own width

Without any <col>, the columns of a <tabular> divide its width evenly, so a column of two-digit numbers is drawn as wide as a column of sentences. One <col width="…"> per column fixes that.


Example: fewer <col> than columns

The <col> components apply to the leftmost columns. Any column past the last <col> is left alone, and the columns with no width of their own share out whatever width remains.

Attribute Examples

Attribute Example: width

The width attribute sets the width of the column as a percentage of the width of the <tabular>. Express it as a percentage rather than as a number of pixels: a percentage is what survives conversion of the document to PreTeXt.


Attribute Example: halign

The halign attribute sets the horizontal alignment of every <cell> in the column, which is the usual way to right-align a column of numbers. The available options are start, center, end, and justify; start and end follow the writing direction, so end is the right edge in a left-to-right document and the left edge in a right-to-left one. An empty <col /> is a placeholder that leaves its column alone — here it holds the first column’s place so that halign="end" lands on the second.

A <col> is the third of four places an alignment can come from. A <cell> uses its own halign if it has one, then its <row>’s, then its column’s, then the <tabular>’s — so the <cell halign="center"> in the last row above outranks the column, and a <row halign="…"> would too.


Attribute Example: topBorder/endBorder

endBorder draws a dividing line down the trailing edge of the column — its right edge in a left-to-right document — and topBorder draws one across the top of it. Both accept none (default), minor, medium, and major. As with halign, a <cell endBorder="…"> of its own takes precedence over the column’s, including endBorder="none" to leave a gap in the line.

A <cell colSpan="…"> covers more than one column, so it follows two of them: it aligns with the first column it covers, where its content begins, and takes its endBorder from the last, where its trailing edge falls. The endBorder of a column that the cell swallows whole is not drawn, because there is no cell edge in the middle of the span to draw it on.

Property Examples

Property Example: Attributes as properties

The attributes of the <col> component are also accessible as properties.

Last updated on