Table

Create structured content in rows and columns to display information.

This block is available in the latest version of WordPress and does not require the Gutenberg plugin.

Last updated

Category:

For developers

Block Grammar & Markup

<!-- wp:core/table -->
<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>Version</th><th>Musician</th><th>Date</th></tr></thead><tbody><tr><td><a href="https://wordpress.org/news/2003/05/wordpress-now-available/">.70</a></td><td>No musician chosen.</td><td>May 27, 2003</td></tr><tr><td><a href="https://wordpress.org/news/2004/01/wordpress-10/">1.0</a></td><td>Miles Davis</td><td>January 3, 2004</td></tr><tr><td>Lots of versions skipped, see <a href="https://codex.wordpress.org/WordPress_Versions">the full list</a></td><td>…</td><td>…</td></tr><tr><td><a href="https://wordpress.org/news/2015/12/clifford/">4.4</a></td><td>Clifford Brown</td><td>December 8, 2015</td></tr><tr><td><a href="https://wordpress.org/news/2016/04/coleman/">4.5</a></td><td>Coleman Hawkins</td><td>April 12, 2016</td></tr><tr><td><a href="https://wordpress.org/news/2016/08/pepper/">4.6</a></td><td>Pepper Adams</td><td>August 16, 2016</td></tr><tr><td><a href="https://wordpress.org/news/2016/12/vaughan/">4.7</a></td><td>Sarah Vaughan</td><td>December 6, 2016</td></tr></tbody></table></figure>
<!-- /wp:core/table -->

Block Attributes

Optional. Type: Object.

Attributes provide the structured data needs of a block. They can exist in different forms when they are serialized, but they are declared together under a common interface.

Documentation

{
  "hasFixedLayout": {
    "type": "boolean",
    "default": false
  },
  "caption": {
    "type": "rich-text",
    "source": "rich-text",
    "selector": "figcaption"
  },
  "head": {
    "type": "array",
    "default": [],
    "source": "query",
    "selector": "thead tr",
    "query": {
      "cells": {
        "type": "array",
        "default": [],
        "source": "query",
        "selector": "td,th",
        "query": {
          "content": {
            "type": "rich-text",
            "source": "rich-text"
          },
          "tag": {
            "type": "string",
            "default": "td",
            "source": "tag"
          },
          "scope": {
            "type": "string",
            "source": "attribute",
            "attribute": "scope"
          },
          "align": {
            "type": "string",
            "source": "attribute",
            "attribute": "data-align"
          },
          "colspan": {
            "type": "string",
            "source": "attribute",
            "attribute": "colspan"
          },
          "rowspan": {
            "type": "string",
            "source": "attribute",
            "attribute": "rowspan"
          }
        }
      }
    }
  },
  "body": {
    "type": "array",
    "default": [],
    "source": "query",
    "selector": "tbody tr",
    "query": {
      "cells": {
        "type": "array",
        "default": [],
        "source": "query",
        "selector": "td,th",
        "query": {
          "content": {
            "type": "rich-text",
            "source": "rich-text"
          },
          "tag": {
            "type": "string",
            "default": "td",
            "source": "tag"
          },
          "scope": {
            "type": "string",
            "source": "attribute",
            "attribute": "scope"
          },
          "align": {
            "type": "string",
            "source": "attribute",
            "attribute": "data-align"
          },
          "colspan": {
            "type": "string",
            "source": "attribute",
            "attribute": "colspan"
          },
          "rowspan": {
            "type": "string",
            "source": "attribute",
            "attribute": "rowspan"
          }
        }
      }
    }
  },
  "foot": {
    "type": "array",
    "default": [],
    "source": "query",
    "selector": "tfoot tr",
    "query": {
      "cells": {
        "type": "array",
        "default": [],
        "source": "query",
        "selector": "td,th",
        "query": {
          "content": {
            "type": "rich-text",
            "source": "rich-text"
          },
          "tag": {
            "type": "string",
            "default": "td",
            "source": "tag"
          },
          "scope": {
            "type": "string",
            "source": "attribute",
            "attribute": "scope"
          },
          "align": {
            "type": "string",
            "source": "attribute",
            "attribute": "data-align"
          },
          "colspan": {
            "type": "string",
            "source": "attribute",
            "attribute": "colspan"
          },
          "rowspan": {
            "type": "string",
            "source": "attribute",
            "attribute": "rowspan"
          }
        }
      }
    }
  }
}

Block Supports

Optional. Type: Object.

A set of options that enables or disables block controls in the editor, for example gradient colors or padding.

Documentation

{
  "anchor": true,
  "align": true,
  "color": {
    "__experimentalSkipSerialization": true,
    "gradients": true,
    "__experimentalDefaultControls": {
      "background": true,
      "text": true
    }
  },
  "spacing": {
    "margin": true,
    "padding": true,
    "__experimentalDefaultControls": {
      "margin": false,
      "padding": false
    }
  },
  "typography": {
    "fontSize": true,
    "lineHeight": true,
    "__experimentalFontFamily": true,
    "__experimentalFontStyle": true,
    "__experimentalFontWeight": true,
    "__experimentalLetterSpacing": true,
    "__experimentalTextTransform": true,
    "__experimentalTextDecoration": true,
    "__experimentalDefaultControls": {
      "fontSize": true
    }
  },
  "__experimentalBorder": {
    "__experimentalSkipSerialization": true,
    "color": true,
    "style": true,
    "width": true,
    "__experimentalDefaultControls": {
      "color": true,
      "style": true,
      "width": true
    }
  },
  "__experimentalSelector": ".wp-block-table > table",
  "interactivity": {
    "clientNavigation": true
  }
}

Transforms

Optional. Type: Object.

Transforms provide rules for what a block can be transformed from and what it can be transformed to.

Documentation

Transforms from:


View blocks per attribute or block support: