News for hackers. Stuff that matters.
Re:Write HTML Right by robgibbons on Friday June 10, 2022 @11:21AM (#31695408)
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.
Re:Write HTML Right by clairity on Friday June 10, 2022 @12:47PM (#31696532)
it doesn't work for even slightly complex documents either. there's been a little meme-fad lately around minimalistic html like this, but to claim it's the "right" way to write html is pompous at best.

not closing tags for instance is really asking for future headaches. sure, it works for a simple text list, but not when it gets even a little complicated (add links, images, buttons, etc.). even worse are p tags, where you have to memorize a whole matrix of what it can contain and what breaks out implicitly. with every insertion/deletion, you need to check the list. it's needless mental drag.

Re:Write HTML Right by niconii on Friday June 10, 2022 @02:40PM (#31697880)
You have to know about what breaks out of <p> tags regardless of whether or not you leave off the end tag, though.

<p><div></div></p> is invalid HTML because <div> ends the paragraph, resulting in an unpaired </p>.

Re:Write HTML Right by anjbe on Friday June 10, 2022 @03:01PM (#31698114)
And not just because of that. In XHTML‐as‐XML, where <div> does not implicitly end the paragraph, what you posted is still invalid because <p> cannot contain <div>.
Re:Write HTML Right by aparks517 on Friday June 10, 2022 @11:27AM (#31695500)
I've been using this style - with some tweaks - for web apps too. I don't think I have it completely figured out yet, but it's promising so far. You can view the source of http://lofi.limo/ to see how it's working out.
Re:Write HTML Right by jaywalk on Friday June 10, 2022 @11:37AM (#31695651)
I feel like this style just makes it harder to read and understand the HTML. But hey, if it works for you, great.
Re:Write HTML Right by sph on Friday June 10, 2022 @11:42AM (#31695716)
This is the output of an app/templating system, i.e. not a single HTML page. Have you ever read the HTML of any dynamically generated page? It's unreadable.
Re:Write HTML Right by jaywalk on Friday June 10, 2022 @12:24PM (#31696252)
> This is the output of an app/templating system, i.e. not a single HTML page.

I don't think that's correct. The article is literally talking about how to write HTML, and explaining the benefits of writing it in this style.

Re:Write HTML Right by julianlam on Friday June 10, 2022 @12:52PM (#31696599)
> Have you ever read the HTML of any dynamically generated page? It's unreadable.

Not with that attidude... if you write consistently and with intention, it turns out just fine.

Check out the source for https://try.nodebb.org, for example. Dynamically generated, (mostly) syntactically correct, (mostly) human readable.

Re:Write HTML Right by ryanbrunner on Friday June 10, 2022 @02:11PM (#31697517)
All the HTML code in the app I maintain is pretty readable. At some point of complexity any HTML is difficult to parse, but if I hand-wrote a page in my app I think the HTML would be largely the same.
Re:Write HTML Right by egeozcan on Friday June 10, 2022 @11:23AM (#31695440)
> Indentation _is_ information, which is lost here.

Isn't it a "view" of information? Any sufficiently advanced text editor can recreate it with a simple key combination.

Re:Write HTML Right by robgibbons on Friday June 10, 2022 @11:27AM (#31695508)
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)

Re:Write HTML Right by SkeuomorphicBee on Friday June 10, 2022 @02:32PM (#31697764)
First and foremost, the author advocates for organising documents in a much flatter DOM tree. In this style all major page elements sit at the same hierarchical level, so there is no "mess of nested elements", the is no need for visual indication of hierarchy if there is no hierarchy to begin with.

I think that is a very compelling format for a text-first web page, like a blog post or news article. Of course it is a coding style not well suited for complex web apps with deep hierarchy.

Re:Write HTML Right by niconii on Friday June 10, 2022 @04:02PM (#31698775)
One interesting detail is that a lack of deep nesting was in fact a deliberate design goal for HTML originally, to make WYSIWYG editing more feasible.

http://info.cern.ch/hypertext/WWW/MarkUp/HTMLConstraints.htm...

Re:Write HTML Right by LeonB on Friday June 10, 2022 @11:48AM (#31695796)
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 <td> 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 describing html does have to answer the question of how it represents arbitrarily deep nesting. But I like the answers it’s given for the more common case of structures that are not arbitrarily deep.

Re:Write HTML Right by Jcowell on Friday June 10, 2022 @11:51AM (#31695837)
What’s a TFA?
Re:Write HTML Right by dec0dedab0de on Friday June 10, 2022 @11:58AM (#31695938)
The Fine(or Fucking) Article
Re:Write HTML Right by shkkmo on Friday June 10, 2022 @01:41PM (#31697185)
I always read the 'F' as "Featured"
Re:Write HTML Right by LinuxBender on Friday June 10, 2022 @03:22PM (#31698371)
Urbandictionary agrees. I reprogrammed myself to read it as "Fabulous" using a text replacement addon.
Re:Write HTML Right by nayuki on Friday June 10, 2022 @02:50PM (#31697985)
And this terminology (TFA) comes from at least the Slashdot days, about 20 years ago.
Re:Write HTML Right by anjbe on Friday June 10, 2022 @03:06PM (#31698175)
In turn, probably descended from “RTFM”—on Slashdot people who commented despite obviously not having read the article were told to “RTFA,” which eventually led to “TFA” as a general term to refer to the original article.
Re:Write HTML Right by mlok on Friday June 10, 2022 @05:19PM (#31699487)
The "F" has always been "Forementioned" for me.
Re:Write HTML Right by nerdponx on Friday June 10, 2022 @11:38AM (#31695660)
The problem is that HTML has multiple uses. The author is describing the case of authoring content, with HTML used as a markup language. However a lot of websites and web applications use HTML more like a layout and templating engine for a GUI framework.
Re:Write HTML Right by falcolas on Friday June 10, 2022 @11:39AM (#31695673)
Only if the formatter is unaware of HTML. If it can't handle automatically closing <p> tags, then it's unaware and is trying to treat HTML like XML.

Or, to put another way, HTML != DOM, even though HTML can be rendered into a DOM.

Re:Write HTML Right by Something1234 on Friday June 10, 2022 @11:29AM (#31695530)
Sometimes I indent in a way that my text editor doesn't exactly understand to better state where complex expressions begin and end.
Re:Write HTML Right by jahewson on Friday June 10, 2022 @11:29AM (#31695521)
I don’t think the author means the information-theory kind of information. I could gzip the file without a loss in that kind of information.
Re:Write HTML Right by jahewson on Friday June 10, 2022 @11:27AM (#31695496)
Incorrect indentation is therefore misinformation.
Re:Write HTML Right by LeonB on Friday June 10, 2022 @11:49AM (#31695813)
Hi guido!
Re:Write HTML Right by pwdisswordfish9 on Friday June 10, 2022 @11:46AM (#31695766)
That’s why HTML is not a language for ‘apps’.
Re:Write HTML Right by Spivak on Friday June 10, 2022 @11:51AM (#31695836)
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 by WillusFredus on Friday June 10, 2022 @12:15PM (#31696154)
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 by ryanbrunner on Friday June 10, 2022 @02:14PM (#31697560)
Sure, but that's an argument for creating new paradigms for having instantly available non-downloaded "apps". Right now, if you want a lot of what a webapp offers (100% cross-compatibility with any platform, instant updates, online syncing for free), you're basically stuck with HTML / Javascript.
Re:Write HTML Right by TedDoesntTalk on Friday June 10, 2022 @02:47PM (#31697958)
> What really needs to happen it a separation of HTML from UI markup elements

Do you mean CSS? Using <b>, <I>, <strong>, etc has been “bad form” for a while (maybe not strong though)

Re:Write HTML Right by frosted-flakes on Saturday June 11, 2022 @11:25AM (#31705179)
<strong> and <em> are the recommended ways to semantically bold and italicize text. <b> and <i> don't have any semantics and can still be used where it makes sense.