---
title: "Element <cell>"
source: https://dev.pageseeder.com/psml/elements/element-cell.html
description: "PSML Element reference for <cell>"
last_updated: 2026-08-07T17:09:54+10:00
tokens: ~1381
---

# \<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](../datatypes/pageseeder_datatypes.md) | no | Horizontal alignment of text within the cell |
| colspan | [xs:positiveInteger](../datatypes/xml_schema_datatypes.md) | 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](../datatypes/pageseeder_datatypes.md) | no | Vertical alignment of text within the cell (**deprecated** – use `@role`) |
| width | [length](../datatypes/pageseeder_datatypes.md) | 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. 

> **Note:** 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:   ```lang-xml <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.

> **Deprecated:** As of PSML beta 7, this attribute is deprecated. Use `@role` and a custom [document style](../../guide/configuration/psml/psml_document_style.md).

### `@width`

Width of the cell in pixels or percent.

> **Deprecated:** As of PSML beta 7, this attribute is deprecated.

## Examples

### Table with single cell 

Table with a single cell:

```lang-xml

<table>
  <row>
    <cell>unicell</cell>
  </row>
</table>
```

### Table with headers

Table with the first column and first row as headers:

```lang-xml

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

```lang-html

<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

```lang-xml

<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

```lang-relax

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.

