Generic Attributes on table columns #496

Closed
opened 2026-01-29 14:38:09 +00:00 by claunia · 1 comment
Owner

Originally created by @peter3 on GitHub (Jan 18, 2022).

I am trying to set aria-label attributes on a table header, but I can't get it to work

This is the original md:

|Width { aria-label='width' }|Length { aria-label='length' }|
|---------|---------|
|80cm|200cm|
|90cm|200cm|
|90cm|210cm|
|90cm|220cm|

This renders (ignore the aria-labelledby - it is inserted via javascript because I found no way to add a caption):

<table class="table-dimensions" aria-labelledby="dimensions-heading" aria-label="width">
<thead>
<tr>
<th>Width</th>
<th>Length</th>
</tr>
</thead>
<tbody>
<tr>
<td>80cm</td>
<td>200cm</td>
</tr>
<tr>
<td>90cm</td>
<td>200cm</td>
</tr>
<tr>
<td>90cm</td>
<td>210cm</td>
</tr>
<tr>
<td>90cm</td>
<td>220cm</td>
</tr>
</tbody>
</table>

The call to Markdig looks like this:

var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
return Markdown.ToHtml($"{{.table-dimensions}}\n{dimensions}", pipeline);

(dimensions is the markdown string)

What am I doing wrong?

Originally created by @peter3 on GitHub (Jan 18, 2022). I am trying to set aria-label attributes on a table header, but I can't get it to work This is the original md: ``` |Width { aria-label='width' }|Length { aria-label='length' }| |---------|---------| |80cm|200cm| |90cm|200cm| |90cm|210cm| |90cm|220cm| ``` This renders (ignore the aria-labelledby - it is inserted via javascript because I found no way to add a caption): ``` <table class="table-dimensions" aria-labelledby="dimensions-heading" aria-label="width"> <thead> <tr> <th>Width</th> <th>Length</th> </tr> </thead> <tbody> <tr> <td>80cm</td> <td>200cm</td> </tr> <tr> <td>90cm</td> <td>200cm</td> </tr> <tr> <td>90cm</td> <td>210cm</td> </tr> <tr> <td>90cm</td> <td>220cm</td> </tr> </tbody> </table> ``` The call to Markdig looks like this: ``` var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build(); return Markdown.ToHtml($"{{.table-dimensions}}\n{dimensions}", pipeline); ``` (dimensions is the markdown string) What am I doing wrong?
claunia added the question label 2026-01-29 14:38:09 +00:00
Author
Owner

@xoofx commented on GitHub (Jan 28, 2022):

I don't think attributes on column are supported. At some point, when you start to use heavily HTML attributes, it might be better to just write the HTML table directly:

<table class="table-dimensions" aria-labelledby="dimensions-heading" aria-label="width">
<thead>
<tr><th>Width<th>Length
<tbody>
<tr><td>80cm<td>200cm
<tr><td>90cm<td>200cm
<tr><td>90cm<td>210cm
<tr><td>90cm<td>220cm
</table>
@xoofx commented on GitHub (Jan 28, 2022): I don't think attributes on column are supported. At some point, when you start to use heavily HTML attributes, it might be better to just write the HTML table directly: ```html <table class="table-dimensions" aria-labelledby="dimensions-heading" aria-label="width"> <thead> <tr><th>Width<th>Length <tbody> <tr><td>80cm<td>200cm <tr><td>90cm<td>200cm <tr><td>90cm<td>210cm <tr><td>90cm<td>220cm </table> ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#496