Table with multiple header rows

is it possible to do multiple header rows within one table ?
here is an example of what i want made with html (header row: Name | Age ):
Unbenannt
when creating a table with right click → insert → table, is it possible to achieve this ?

This isn’t possible with Markdown code, this is only possible with pure HTML code, which unfortunately Obsidian doesn’t allow mixing with Markdown code, so whatever goes in your table rows/cells will have to be pure HTML as well, not Markdown.

Here’s an example of HTML table with multiple headers:

<table>

<thead>
<tr><th>H1</th><th>H2</th></tr>
</thead>

<tr><td>C1</td><td>C2</td></tr>

<thead>
<tr><th>H3</th><th>H4</th></tr>
</thead>

<tr><td>C3</td><td>C4</td></tr>

</table>

Result in Obsidian:

Screenshot-28_02_2024-17.08.44

But again, if you put markdown code in those cells it will simply not render as markdown and will be considered plain text (so if you want to use bold text, you have to use <strong>bold text</strong>, NOT **bold text**

P.S. or you could just create 2 markdown tables one after the other to emulate something similar, and remove the spacing between them using a CSS snippet.

1 Like

Do note that having multiple <thead> is not legal according to the HTML specifications. You can however have multiple <th> in a table. So I’m considering writing some addon using dataviewjs in combination with await dv.query(), which would simply repeat the header row or rebuild the header row at a given interval.

I also saw a nifty trick recently which made multiple <tbody> groups, and then used CSS to style the first row of each <tbody> as a header row. That concept could possibly also be expanded upon if one would want to look into doing this programmatically. (Actually I’m considering whether this could be added to dataview as sort of an extra CONFIGURE option feature extension (alongside of doing some automatic rowspan on similar values in a given column). But I’m rambling/dreaming/… )

2 Likes

In my own case, I had to use multiple theads to trigger the proper styling I have in place.

As for legal… that wording comes across as a bit harsh, I mean it’s not like the cops will be on to me for writing such a monstrosity :sweat_smile: I can almost imagine it:

— *cops breaking the door*
“Freeze! You’re under arrest for technology misuse and spreading illegal misinformation! You will never be allowed to use HTML tables again!”

:rofl:

1 Like

Hehe… I do get your sentiment, and didn’t want to be harsh towards you in particular. Just wanted to point out the non-conformity of that solution towards the specification.

Have those specifications been broken before? And will they be broken agsin? Oh yes, but still I’m trying to conform to them if possible.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.