Live data from Hacker News

Write HTML Right

lofi.limo

31–40 of 212 posts

Re: Write HTML Right

#31

This works for blog posts, where the body of the document is one long block of paragraphs, but I suspect this style would quickly become untenable for complex apps. Indentation _is_ information, which is lost here.

That’s why HTML is not a language for ‘apps’.

Except for the fact that native apps also use SGML or XML inspired markup for their layout engines. A tree of heterogeneous objects maps extremely well to how people think about UI.

Re: Write HTML Right

#32
post #29

Earlier quoted context omitted.

Sure, but the author is advocating that you compose HTML this way. It would quickly become a mess of nested elements with zero visual indication of hierarchy. The DOM is a tree, with nested elements. Losing that information doesn't get you anything but tag soup (which is, oddly, what the author suggests this style is supposed to avoid)

In a tree you have branches off branches off branches etc. You can’t orient yourself - you can’t tell where you are - unless you count the branches. And indenting makes that visible. In the examples for TFA, you can tell your location from the names of the elements. Eg is enough for you to know you’re probably inside a tr inside a table. And that is the more common case than the general tree example. But a method of…

What’s a TFA?

Re: Write HTML Right

#33

In 2022 how often do you actually write text by hand in your HTML files? I find that beside the few buttons here and there (and that's if you don't have i18n), text is always going to be served by a server. In 2022 we also all use text editors or IDEs that can collapse entire blocks of tags, to improve readability. I'm not sure I can see a clear benefit here outside of very few edge cases, and I am sure it comes with…

Static site generators (Jekyll, Hugo) are one example. Sometimes you can get away with markdown but often you end up marking up pages of text.

Re: Write HTML Right

#34
post #32
post #29

Earlier quoted context omitted.

In a tree you have branches off branches off branches etc. You can’t orient yourself - you can’t tell where you are - unless you count the branches. And indenting makes that visible. In the examples for TFA, you can tell your location from the names of the elements. Eg is enough for you to know you’re probably inside a tr inside a table. And that is the more common case than the general tree example. But a method of…

What’s a TFA?

The Fine(or Fucking) Article

Re: Write HTML Right

#35
Although, as the article correctly points out, omitting the HTML tag is technically fine, there is one rather important argument for its inclusion: it can and should have a LANG attribute:

    
It's not verbose after all, and IIUC may be omitted if and only if the document is served with corresponding information in `Content-Language:` HTTP header, but nasty (or rather annoying) things may happen if that fails [1], so when it comes to "right HTML", following this advice sounds reasonable.

[1] https://adrianroselli.com/2015/01/on-use-of-lang-attribute.h...

Re: Write HTML Right

#36
Why does it matter? A good HTML editor ought to be able to take in HTML, display it and edit it according to the user's preferences, and save it in a size-minimizing way. Why should we have to choose only one way?

Re: Write HTML Right

#37
post #25
post #13

This is how SingleFile writes HTML by default :). However, it is also the most duplicated issue in the tracker.

You can link it: https://github.com/gildas-lormeau/SingleFile Pretty neat extension!

I was hesitating, thanks!

Re: Write HTML Right

#38
post #28

Closing li tags is the right thing to do! I always close the kitchen drawer too after putting the scissors back. But I rarely write HTML as content anyway, it's mostly templates for the CMS, where it's best to close the tags.

I too close my kitchen drawers. But not my li tags. Unless I'm using the bastardization known as jsx. The next li closes it automatically, as it's specified to do.

Re: Write HTML Right

#39
post #31

Earlier quoted context omitted.

That’s why HTML is not a language for ‘apps’.

Except for the fact that native apps also use SGML or XML inspired markup for their layout engines. A tree of heterogeneous objects maps extremely well to how people think about UI.

I agree that a tree structure can work well for mapping UIs, but HTML does not. It was specifically design as a textual markup language. Its role has been expanded, but it has been done so poorly.

What really needs to happen it a separation of HTML from UI markup elements. HTML will be used solely for textual markup and a new markup language can be used for UIs. This would allow us to return to a proper separation of concerns.

Re: Write HTML Right

#40

Earlier quoted context omitted.

…for non-tabular data such as “your pretty design elements that frame and organize the text because it is 1995 and CSS doesn’t exist yet and this is the only tool at your disposal for aligning stuff across the page”. Or because it is 2000 and putting stuff where you want it is a hell of CSS2 floats and box models and eventually you just say “fuck it” and assign table-like behavior to a bunch of divs because Tables Fo…

It’s funny you bring this up because while I have joined the Tables For Layout Are Considered Harmful club, I never really have heard a completely convincing argument on why tables have this bad rap. I think it’s mostly because, semantically, tables don’t make sense for layout, but back in the days before frameworks such as Foundation and Bootstrap (and more recently native CSS3 mechanisms), tables with invisible bor…

Doing layout with tables creates a mess of non-semantic cells, with spans everywhere. That is hard to read, hard to write, brittle on changes, and obscure the actual content. If you take a random page from the tables era, the odds are great that you won't be able to tell what text goes next to what other text.

Divs that follow the document's semantic hierarchy and are positioned on your CSS have none of those issues.

Anyway, a lot of ways to use Bootstrap and other grid-based frameworks introduce the same problems back. And if you want to really display things in a table, well, a table fits quite well your requirements.

Post reply on HN