Header tags don't seem to work inside tables, is there a way to get them to work?
Example code:
# Header 1
## Header 2
### Header 3
#### Header 4
##### Header 5
###### Header 6
**bold**
*italic*
| # Header 1 |
| --- |
| ## Header 2 |
| ### Header 3 |
| #### Header 4 |
| ##### Header 5 |
| ###### Header 6 |
| **bold** |
| *italic* |
Additionally, is there a way to create a table without it using the <th> for the first row which formats the data as a table header?
Header tags don't seem to work inside tables, is there a way to get them to work?
Using HTML directly inside tables.
| <h1>header1</h1> |
| --- |
| **bold** |
| *italic* |
Additionally, is there a way to create a table without it using the
for the first row which formats the data as a table header? No. We needed to standardize the table output and using thead and th seemed the semantically correct way,
Ideally I don't want to tell our users to use HTML, that's the whole reason we're using markup 馃槃
To add to the explanation, there are 2 reasons why you can't use headings inside tables.
According to the HTML living standard, the th element's content model only allows
for "Flow content, but with no header, footer, sectioning content, or heading content descendants." This means h1 isn't allowed inside th elements. So this...| # Header 1 | | --- | | foo |would result in non compliant generated HTML.
The other reason is that headings, in markdown, are treated as block elements (not span/inline elements). Block elements require, at least, one line break (\n) or a EOF at the end.
Due to the nature of markdown tables' syntax, this is not possible, and that's the reason why only inline/span markdown elements are allowed in markdown's table cells.
Please note that, concerning HTML spec, and contrary to th elements, heading elements are perfectly valid in table bodies (td elements). So you can "cheat" around this using HTML directly.
As a final note, I don't know of any other markdown specification or implementation that allows headings in tables.
Thank you for the reply, I hadn't realised having headers inside tables was a "bad" thing. Will have think around this.
I will be closing this issue. If you feel there's something else you wish to add, please feel free to reopen it.
Was this page helpful?0 / 5 - 0 ratingsRelated issues
buremba 路 4Comments
subodhpareek18 路 5Comments
jeud 路 3Comments
evanplaice 路 3Comments
KirkMunro 路 6Comments