Live data from Hacker News

Do you know that there is an HTML tables API?

christianheilmann.com

101–110 of 206 posts

Re: Do you know that there is an HTML tables API?

#102
post #34

Abandoned? When? I still use this pretty much everywhere to create HTML tables. Do people use something else now?

People often use declarative UI frameworks such as React, Svelte etc. when they want to build things dynamically in JS like that now, so imperative DOM manipulation APIs have unsurprisingly become a little more niche.

Re: Do you know that there is an HTML tables API?

#103

Earlier quoted context omitted.

I mean, you can just remove all the user agent styles and then is just as stylable as .

Why would marketing want to pay for the extra (and to their mind entirely pointless) work required to capture semantics? (I’m not saying I like the world we live in, but I don’t see a likely alternative.)

Because not everyone has useful eyeballs. Some people are blind. The amount of extra work you have to do to make a div faithfully act like a button is far more than simply resetting some styles.

Re: Do you know that there is an HTML tables API?

#104

Phew, this post single handedly made me feel old this morning. I started dabbling with the web just over 20 years ago but have mainly been working on the backend the past 10-15 years. I had no clue that nowadays programmers don’t know about this, so I assume it’s supplanted by modern frameworks or modern JS/CSS

HTML tables are cognitively if not officially deprecated these days. I made my 1996 resume in HTML using a table for layout and it was indistinguishable from the Word version when printed. Made by editing the HTML by hand too! Tables are great. I don't doubt that CSS stuff is more capable, but the old ones are still useful.

I think the problem was that tables were always supposed to be for things that look like actual tables in the output - for that purpose they are not deprecated.

What is discouraged is using tables as invisible layout grids - and that was their primary de-facto usecase before CSS and grid layouts. But that had always been a hack, even though a necessary one.

Re: Do you know that there is an HTML tables API?

#105
post #15

Interesting, but the JavaScript examples hurt: let table = [ ['one','two','three'], ['four','five','six'] ]; let b = document.body; let t = document.createElement('table'); b.appendChild(t); table.forEach((row,ri) => { let r = t.insertRow(ri); row.forEach((l,i) => { let c = r.insertCell(i); c.innerText = l; }) }); Use full words for variable names!

>Use full words for variable names!

that's like saying in spoken language "don't ever use pronouns, or even first or nicknames, use full given names"

Re: Do you know that there is an HTML tables API?

#106
post #15

Interesting, but the JavaScript examples hurt: let table = [ ['one','two','three'], ['four','five','six'] ]; let b = document.body; let t = document.createElement('table'); b.appendChild(t); table.forEach((row,ri) => { let r = t.insertRow(ri); row.forEach((l,i) => { let c = r.insertCell(i); c.innerText = l; }) }); Use full words for variable names!

> let b = document.body;

This one hurts the most. Save a few bytes for an ungodly amount of mental friction.

Re: Do you know that there is an HTML tables API?

#107
post #64
post #50

Earlier quoted context omitted.

Yes, React

And what does that use internally to manage tables? Just because there is layer between you and the API, it doesn't mean API is abandoned.

Are you implying that when doing DOM reconciliation, React uses these table-specific insertRow/insertCell APIs for adding and removing elements in tables instead of the regular DOM element APIs it would use for all other elements? I would be surprised if that's the case.

Re: Do you know that there is an HTML tables API?

#108
> Without having to re-render the whole table on each change.

Not quite sure what the author means by that. Re-rendering pnly happens when the current task queue elemt has been processed. Never while JS is running (aside from webworker and the like). I would honestly be surprised if this API had much (if any) performance benefits over createElement.

Re: Do you know that there is an HTML tables API?

#109
post #34

Abandoned? When? I still use this pretty much everywhere to create HTML tables. Do people use something else now?

People often use declarative UI frameworks such as React, Svelte etc. when they want to build things dynamically in JS like that now, so imperative DOM manipulation APIs have unsurprisingly become a little more niche.

If by “Niche” you mean “not hype” then yes, but the PHP+jQuery combo is still very widely used in 2025 (likely more than React, given WordPress market share alone).

Re: Do you know that there is an HTML tables API?

#110
post #2

Tables died (thankfully) to make room for flex and grid. I can't see any use case for them at all anymore.

I agree with many other replies here, specifically about accessibility. Once I learned how to use a screen reader, it was eye-opening. So many web applications are utterly broken for users with assistive technologies.

Tables built with flex and grid absolutely can be made accessible with WAI-ARIA, but native table elements are harder to mess up.

Post reply on HN