This post needs an OCD trigger warning.
Write HTML Right
191–200 of 212 posts
Re: Write HTML Right
#192Earlier 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)
Re: Write HTML Right
#193Author: 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.
Re: Write HTML Right
#194Re: Write HTML Right
#195Earlier 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…
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
#196Earlier 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.
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
#197This 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
#198Earlier 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.
Re: Write HTML Right
#199Earlier 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).
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
#200Earlier 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.