<cell>
Summary
Represents a single cell in a table.
It only appears inside a <row>
element but can also inherit properties from <col>
element.
Usage context
Element category | table |
---|---|
PSML level | portable |
Permitted content | |
Permitted parent | <row> |
HTML equivalent | <td> or <th> |
OpenXML equivalent | <w:tc> |
Attributes
This element includes the following attributes
Name | Type | Required | Description |
---|---|---|---|
align | alignment | no | Horizontal alignment of text within the cell |
colspan | xs:positiveInteger | no | How many columns the cell extends to |
role | xs:string | no | Custom value that can be used for formatting |
rowspan | xs:positiveInteger | no | How many rows the cell extends to |
valign | alignment | no | Vertical alignment of text within the cell (deprecated – use @role ) |
width | length | no | Width of the cell in pixels or percent (deprecated – use <col>/@width ) |
@align
Horizontal alignment of the text within the cell.
Possible values are:
center
justify
left
right
@colspan
A natural integer to indicate how many columns the cell extends to.
The default value is 1, meaning that the cell only extends to the current column. A value greater than the number of available columns is not an error in PageSeeder, but it is likely to cause problems when formatted.
When a cell extends beyond its current column, it only inherits the properties of the leftmost column it belongs to.
@role
A custom value to provide semantics for the cell. This can be used for formatting.
@rowspan
A natural integer to indicate how many rows the cell extends to.
The default value is 1, meaning that the cell only extends to the current row. A value greater than the number of available rows is not an error in PageSeeder, but it is likely to cause problems when formatted.
When a cell extends beyond the current row, it only inherits the properties of the first row it belongs to.
Cells in header rows that span non-header rows are NOT displayed correctly in PageSeeder and NOT supported in HTML, the following example is incorrect:
<table> <row part="header"> <cell rowspan="2">Drug</cell> <cell>Dose</cell> </row> <row> <cell>(ml)</cell> </row> ... </table>
@valign
Vertical alignment of text within the cell.
As of PSML beta 7, this attribute is deprecated.
@width
Width of the cell in pixels or percent.
As of PSML beta 7, this attribute is deprecated.
Examples
Table with single cell
Table with a single cell:
<table> <row> <cell>unicell</cell> </row> </table>
Table with headers
Table with the first column and first row as headers:
<table> <col part="header"/> <row part="header"> <cell>Name</cell> <cell>Score</cell> </row> <row> <cell>Alice</cell> <cell>17</cell> </row> <row> <cell>Bob</cell> <cell>19</cell> </row> </table>
This would be generally be represented in HTML as:
<table> <thead> <tr> <th>Name</th> <th>Score</th> </tr> </thead> <tbody> <tr> <th>Alice</th> <td>17</td> </tr> <tr> <th>Bob</th> <td>19</td> </tr> </tbody> </table>
Schema
XML Schema
<xs:element name="cell" type="cell-style"> <xs:complexType> <xs:attribute name="role" type="role"/> <xs:attribute name="align"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="left" /> <xs:enumeration value="center" /> <xs:enumeration value="right" /> <xs:enumeration value="justify" /> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute name="valign"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="top" /> <xs:enumeration value="middle" /> <xs:enumeration value="bottom" /> <xs:enumeration value="baseline" /> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute name="width"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="[0-9\.]+(px|%)?"/> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute name="colspan" type="xs:positiveInteger"/> <xs:attribute name="rowspan" type="xs:positiveInteger"/> </xs:complexType> </xs:element>
Relax Schema
element cell { attribute role { role }?, attribute colspan { xs:positiveInteger }?, attribute rowspan { xs:positiveInteger }?, attribute align { "center" | "justify" | "left" | "right"}?, attribute valign { "top" | "middle" | "bottom" | "baseline"}?, attribute width { text {pattern: "[0-9\.]+(px|%)?" } }?, (character-style-group | list | nlist | para | block | blockxref | image | preformat)* }
Compatibility
This element was introduced in the first draft of PSML and is well-supported from PageSeeder 5.1.