Live data from Hacker News

Do you know that there is an HTML tables API?

christianheilmann.com

171–180 of 206 posts

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

#171
post #86

Earlier quoted context omitted.

Declarative frameworks build on the imperative DOM API.

They don't use .insertRow() and .insertCell(). Try searching the React codebase for those.

Yea, but that's pretty much irrelevant as long as the effect is exactly the same. Which brings us back to the point of the article: seeing this and feeling inspired to imagine interface extensions that go beyond syntax sugar.

I was replying to the wrong comment, because I was responding to this:

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

Regarding React: what would be the benefit for using this old syntax sugar in its vDOM implementation?

Page reflow is not an issue for vDOM as it batches such updates anyway?

And using syntax sugar without benefits in the DOM reconciliation would be pointless.

React also doesn't locate form input elements using document.forms.[name]?.[name] because... why should they?

Just because they can...

Regarding the creation of tables, the most common way to do it would be... parsing initial document's HTML?!

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

#173

Earlier quoted context omitted.

How about displaying data in rows and columns, like records in a database? Or have you forgotten SQL, because you retrieve JSON from your 1000 NoSQL microservices?

Rows and columns are exactly what grid was added to CSS for.

Using only CSS for tabular row and column data is just as wrong as using tables for layout. There are legit reasons for using today that can't be replicated by CSS. Namely, CSS doesn't confer the same semantic meaning into markup that does.

Compare https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/...

with https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_la...

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

#174
post #104

Earlier quoted context omitted.

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.

> What is discouraged is using tables as invisible layout grids - and that was their primary de-facto usecase before CSS and grid layouts.

After too.

I've seen enough "Introduction to CSS"s filled with caveats and hemming & hawing to know that it's all to be avoided when+if possible. I know, I know, there's a whole wide wonderful world out there full of aligns and borders and containers and insets and margins and masks and offsets and paddings and positions oh my. Bleccch..

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

#175
post #147
post #142

Earlier quoted context omitted.

Sorry I - also - am one of those old timers who don't understand this because the shown code is all I've ever used for creating table. So, what is this "standard DOM API" if I may ask? Could you post a code example?

You can use document.createElement and document.appendChild to create every last , , and if you want. Those functions are not specific to tables, unlike the one mentioned in the blog post. They can be used to create any elements and place them in the DOM. But if you know what you are doing you can get a perfectly fine table out of that. (Not that you should.)

Yeah, that was what I was thinking of. I knew those as the essential APIs to modify the DOM without a full re-parse. And you can use them on table/th/tr/td nodes just like on any other node.

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

#176
post #23

It is similar as with buttons ( https://news.ycombinator.com/item?id=45774182 ). Not sure when it was (10-15 years ago), but at some point everything became s. So, instead of semantic markup, HTML became a UI toolbox.

I've been writing HTML for at least 20 years professionally and this has absolutely not been my experience. Yes, I've encountered some people using divs for everything but in the vast majority of cases people have used semantically correct HTML, at least when it comes to buttons.

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

#177

Earlier quoted context omitted.

Yes, and the reason for why that's OK is that the context is just few lines. But this is borderline due to the amount of variables. In just 4 lines you have r, row, t, ri, l, i and c. The full variables names are so short anyway that personally I'd write them out. Code does evolve and there's a risk of this suffering as a result.

rowIndex isn’t that short.

We might be able to use rowIx? Let's discuss it on the next Monday standup. Everyone will need to have an opinion, max 5 minutes per person.

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

#178
post #56

Earlier quoted context omitted.

The worst thing on the modern web is people using divs for table data. What do you mean this table isn’t sortable? M365 Admin is the worst offender I’ve come across on this. Just terrible table implementations on almost every page.

Is there a term for the opposite of cargo culting? Where everyone avoids something, but no one remembers why? Because that’s basically where HTML tables have ended up.

It's still cargo culting

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

#179

A lot of people here are clearly not reading the article. It’s not about the element itself—we hope everyone knows about tables—but rather about the table-specific DOM interface, including things like HTMLTableElement.prototype.insertRow() and HTMLTableRowElement.prototype.insertCell() as alternatives to the generic DOM techniques like Document.prototype.createElement() and Node.prototype.appendChild(). These are han…

I feel like frameworks have taken over and so few people know the foundations anymore. Thank you.

I still remember reading a news article on C|net about the addition of the element.

Yeah, I'm old.

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

#180
post #56

Earlier quoted context omitted.

The worst thing on the modern web is people using divs for table data. What do you mean this table isn’t sortable? M365 Admin is the worst offender I’ve come across on this. Just terrible table implementations on almost every page.

Is there a term for the opposite of cargo culting? Where everyone avoids something, but no one remembers why? Because that’s basically where HTML tables have ended up.

I would guess that people became so afraid of being accused of using tables for layout that they don't use them at all.
Post reply on HN