1title: Tables Extension 2 3Tables 4====== 5 6Summary 7------- 8 9The Tables extension adds the ability to create tables in Markdown documents. 10 11This extension is included in the standard Markdown library. 12 13Syntax 14------ 15 16Tables are defined using the syntax established in [PHP Markdown Extra][php]. 17 18[php]: http://www.michelf.com/projects/php-markdown/extra/#table 19 20Thus, the following text (taken from the above referenced PHP documentation): 21 22```md 23First Header | Second Header 24------------- | ------------- 25Content Cell | Content Cell 26Content Cell | Content Cell 27``` 28 29will be rendered as: 30 31```html 32<table> 33 <thead> 34 <tr> 35 <th>First Header</th> 36 <th>Second Header</th> 37 </tr> 38 </thead> 39 <tbody> 40 <tr> 41 <td>Content Cell</td> 42 <td>Content Cell</td> 43 </tr> 44 <tr> 45 <td>Content Cell</td> 46 <td>Content Cell</td> 47 </tr> 48 </tbody> 49</table> 50``` 51 52!!! seealso "See Also" 53 The [Attribute Lists](./attr_list.md) extension includes support for defining attributes on table cells. 54 55Usage 56----- 57 58See [Extensions](index.md) for general extension usage. Use `tables` as the 59name of the extension. 60 61See the [Library Reference](../reference.md#extensions) for information about 62configuring extensions. 63 64The following options are provided to change the default behavior: 65 66* **`use_align_attribute`**: Set to `True` to use `align` instead of an appropriate `style` attribute 67 68 Default: `'False'` 69 70 71A trivial example: 72 73```python 74markdown.markdown(some_text, extensions=['tables']) 75``` 76 77### Examples 78 79For an example, let us suppose that alignment should be controlled by the legacy `align` 80attribute. 81 82```pycon 83>>> from markdown.extensions.tables import TableExtension 84>>> html = markdown.markdown(text, 85... extensions=[TableExtension(use_align_attribute=True)] 86... ) 87``` 88