Markdown table rendered by Hugo includes invalid HTML

  • I searched and could not find a related thread or GitHub issue.

Not sure if this is a feature or problem, hence this thread.

When I make a centred table like this:

Example | Table
------- | :-----:
Hello | there
this | is
an | example

Then Hugo 0.51 renders that into the following HTML:

<table>
<thead>
<tr>
<th>Example</th>
<th align="center">Table</th>
</tr>
</thead>

<tbody>
<tr>
<td>Hello</td>
<td align="center">there</td>
</tr>

<tr>
<td>this</td>
<td align="center">is</td>
</tr>

<tr>
<td>an</td>
<td align="center">example</td>
</tr>
</tbody>
</table>

If I am to believe the official W3C HTML validator then this is invalid HTML. I get complaints about:

Error : The align attribute on the td element is obsolete. Use CSS instead.

Can we fix this? I’d love to have my markup to be valid.

1 Like

Hugo uses Blackfriday for markdown, so if you open an issue, I think it makes sense to open it there.

Don’t center the second column. And add a CSS code like:

<style>
td + td { align: center: }
</style>
1 Like

Okay, thanks. Make the issue here. :slight_smile:

1 Like

Hi.
If you cannot pass through CSS, you can still use ReplaceRE to replace all td align=“center” to td style=“text-align: center”.

See my post here : How to Customise Tables