Live data from Hacker News

Write HTML Right

lofi.limo

191–200 of 212 posts

Re: Write HTML Right

#191

This post needs an OCD trigger warning.

"OCD" as in "I don't like clutter" or real OCD as in "if I don't clear away the clutter my family will die in a car crash, I know that's illogical, and yet I'm still encumbered with the intrusive thought?"

Re: Write HTML Right

#192

Earlier quoted context omitted.

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…

> What really needs to happen it a separation of HTML from UI markup elements Do you mean CSS? Using , , , etc has been “bad form” for a while (maybe not strong though)

and are the recommended ways to semantically bold and italicize text. and don't have any semantics and can still be used where it makes sense.

Re: Write HTML Right

#193
post #144

Author: write HTML right Me: this green on black background is terrible to read, I'll use reader mode Chrome: this author did not write their HTML correctly, so there is no reader mode available How ironic.

I think Reader mode looks for a section. When it's not present it either guesses or doesn't work at all.

Re: Write HTML Right

#194
Is there a tool to convert an existing HTML document into this style? E.g. strip out optional closing tags, without doing full minimisation/whitespace stripping.

Re: Write HTML Right

#195

Earlier quoted context omitted.

Although there are some other uses for , it is perfectly valid to use tags for textual paragraphs and that has been the main use for for as long as HTML has existed. I'm not sure why you believe otherwise. Take a look at the source code for http://info.cern.ch/hypertext/WWW/MarkUp/Future.html for instance, which was written by the creator of HTML, Tim Berners-Lee. You can also look at the source code for any page of…

I didn't say it's not a valid use, I said that it's not it's primary use. Paragraphs relate to grouping content[1], not textual one. There's no logic in paragraphs. I quote here the official spec, which makes various examples of how paragraphs are not related to logical paragraphs: > The solution is to realize that a paragraph, in HTML terms, is not a logical concept, but a structural one. In the fantastic example ab…

In this comment section? Are you talking about stuff like the example I used earlier?

    

Yes, obviously this is bad and nonsensical HTML. Under no circumstances does it make sense to have a div inside a p. In fact, the above doesn't even work, being parsed as

    

But the intention of this example is not to show good HTML. The point is that many people have only a very basic understanding of HTML syntax, under the impression that

    
works for any elements, because there's a and a so clearly anything inside it must be inside the foo element, right? But this is not the case for all elements. HTML's syntax is more complicated than that. My example was only intended to correct this misconception, not to demonstrate semantically-correct HTML, and that goes for other similar examples made by other people in the comments too.

Re: Write HTML Right

#196

Earlier quoted context omitted.

Read the quoted sentence again (from the source you brought here), none of those clauses apply to: Block of text ... Which is what they do in the article.

I don't understand what you mean. Please elaborate. That quote says that is not needed in many cases. When you say "none of those clauses apply to ", this is true, you can't omit , only ... but the blog article doesn't advocate for omitting at any point.

1. The article omits

liberally.

2. The spec details situations where the

tag may be omitted.

3. None of these (2) apply to what's going on at (1).

Re: Write HTML Right

#197

This post needs an OCD trigger warning.

"OCD" as in "I don't like clutter" or real OCD as in "if I don't clear away the clutter my family will die in a car crash, I know that's illogical, and yet I'm still encumbered with the intrusive thought?"

OCD as in “not having closing tags matching open tags is driving me insane”. Maybe OCD isn’t the proper term, but I don’t know of a better one.

Re: Write HTML Right

#198

Earlier quoted context omitted.

"OCD" as in "I don't like clutter" or real OCD as in "if I don't clear away the clutter my family will die in a car crash, I know that's illogical, and yet I'm still encumbered with the intrusive thought?"

OCD as in “not having closing tags matching open tags is driving me insane”. Maybe OCD isn’t the proper term, but I don’t know of a better one.

Respectfully, please try to refrain from using OCD casually. It's not like you're the only one, but it's a debilitating disease.

Re: Write HTML Right

#199

Earlier quoted context omitted.

I don't understand what you mean. Please elaborate. That quote says that is not needed in many cases. When you say "none of those clauses apply to ", this is true, you can't omit , only ... but the blog article doesn't advocate for omitting at any point.

1. The article omits liberally. 2. The spec details situations where the tag may be omitted. 3. None of these (2) apply to what's going on at (1).

Okay, let's go over this then.

First, let's talk about the basic case where there's no whitespace between the two paragraphs.

    

Paragraph 1

Paragraph 2

In this case, the first

can be omitted according to the rule "A p element's end tag may be omitted if the p element is immediately followed by an [...] p [...] element [...]", resulting in this code:

    

Paragraph 1

Paragraph 2

If we assume that the body ends immediately after this (either because there's a or because we've reached the end of the file, since and are optional tags) then we can remove the second

as well because of the rule "A p element's end tag may be omitted if [...] there is no more content in the parent element and the parent element is an HTML element that is not an a, audio, del, ins, map, noscript, or video element, or an autonomous custom element":

    

Paragraph 1

Paragraph 2

Now, let's get into the case where there is whitespace between the two paragraphs:

    

Paragraph 1

Paragraph 2

In this case, you can't remove the first

, because the rule is that it must be "immediately followed" by another p element. However, what if we start with this code?

    

Paragraph 1

Paragraph 2

In this case, we can remove the first

, resulting in:

    

Paragraph 1

Paragraph 2

and again, we can remove the last

, resulting in:

    

Paragraph 1

Paragraph 2

Now, this is different from what we started with. The whitespace is now inside the first paragraph instead of after it. But since HTML does not render this extra whitespace by default, it's of no real consequence.

And that leads us to this point: the HTML spec is specifying the exact circumstances where you can omit tags without changing the DOM. However, if we are okay with changing the DOM a bit, by moving that whitespace into the first paragraph, then we can simply pretend that we wrote

    

Paragraph 1

Paragraph 2

from the beginning, and apply the rules to that instead.

Re: Write HTML Right

#200

Earlier quoted context omitted.

OCD as in “not having closing tags matching open tags is driving me insane”. Maybe OCD isn’t the proper term, but I don’t know of a better one.

Respectfully, please try to refrain from using OCD casually. It's not like you're the only one, but it's a debilitating disease.

What is a better term to use that means when things are not perfectly matched it drives me so insane that I can't function until I go in there and fix it so that everything is exactly right?
Post reply on HN