Beautiful Soup - close tags more promptly?
Roel Schroeven
roel at roelschroeven.net
Mon Oct 24 14:10:34 EDT 2022
Jon Ribbens via Python-list schreef op 24/10/2022 om 19:01:
> On 2022-10-24, Chris Angelico<rosuav at gmail.com> wrote:
> > On Tue, 25 Oct 2022 at 02:45, Jon Ribbens via Python-list <python-list at python.org> wrote:
> >> Adding in the omitted <head>, </head>, <body>, </body>, and </html>
> >> would make no difference and there's no particular reason to recommend
> >> doing so as far as I'm aware.
> >
> > And yet most people do it. Why?
>
> They agree with Tim Peters that "Explicit is better than implicit",
> I suppose? ;-)
I don't write all that much HTML, but when I do, it include those tags
largely for that reason indeed. We don't write HTML just for the
browser, we also write it for the web developer. And I think it's easier
for the web developer when the different sections are clearly
distinguished, and what better way to do it than use their tags.
>> > More importantly: Would you omit all the </p> closing tags you can, or
>> > would you include them?
> It would depend on how much content was inside them I guess.
> Something like:
>
> <ol>
> <li>First item
> <li>Second item
> <li>Third item
> </ol>
>
> is very easy to understand, but if each item was many lines long then it
> may be less confusing to explicitly close - not least for indentation
> purposes.
I mostly include closing tags, if for no other reason than that I have
the impression that editors generally work better (i.e. get things like
indentation and syntax highlighting right) that way.
--
"Je ne suis pas d’accord avec ce que vous dites, mais je me battrai jusqu’à
la mort pour que vous ayez le droit de le dire."
-- Attribué à Voltaire
"I disapprove of what you say, but I will defend to the death your right to
say it."
-- Attributed to Voltaire
"Ik ben het niet eens met wat je zegt, maar ik zal je recht om het te zeggen
tot de dood toe verdedigen"
-- Toegeschreven aan Voltaire
More information about the Python-list
mailing list