Are you an author writing HTML?
Just so we’re clear: Not XHTML. HTML. Without the X.
If you are, repeat after me, because apparently this bears repeating (after the title):
You are not required to close your
↫ Daniel Tan<p>,<li>,<img>, or<br>tags in HTML.
Back when I still had to write OSNews’ stories in plain HTML – yes, that’s what we did for a very long time – I always properly closed my tags. I did so because I thought you had to, but also because I think it looks nicer, adds a ton of clarity, and makes it easier to go back later and make any possible changes or fix errors. It definitely added to the workload, which was especially annoying when dealing with really long, detailed articles, but the end result was worth it.
I haven’t had to write in plain HTML for ages now, since OSNews switched to WordPress and thus uses a proper WYSIWYG editor, so I haven’t thought about closing HTML tags in a long time – until I stumbled upon this article. I vaguely remember I would “fix” other people’s HTML in our backend by adding closing tags, and now I feel a little bit silly for doing so since apparently it wasn’t technically necessary at all. Luckily, it’s also not wrong to close your tags, and I stick by my readability arguments.
Sometimes it’s easy to forget just how old HTML has become, and how mangled it’s become over the years.

I’m probably an outlier among devs but I always close my `p` and `li` tags but never `img` or `br`. My reasoning is that p and li tags contain content, so it makes sense to specify where the content ends via a closing tag, whereas img and br tags don’t contain content, so they don’t need a closing tag.
emmzee,
Same.
I would agree with the auther on “void elements” that contain no content, but otherwise closing tags should be present to make it clear where that tag ends. The author talking about not closing TR TD because the browser will fix it is not a satisfying reason to leave them off IMHO. The author specifically does not like us saying the browser “fixes” it, but it is kind of what the browser ends up doing internally. It has to know where the sections end for internal representation.
If you input this html and view the debugger tools, the browser’s representation has those closing tags present. The browsers are following the practice of being liberal about the input you accept but being strict output the output you produce, which is considered a good practice in CS.
If someone wants to omit closing tags because the browsers accept it that way, I guess that’s their prerogative. I looked at the HTML behind the author’s website to see if anything stood out. I didn’t not see any examples of unclosed li or even p tags, so despite the author saying they don’t matter, the author’s website still uses closing tags.
I did notice some inconsistency in the meta and link tags though…
It doesn’t really matter because elements don’t contain content, but it’s kind of funny to see both styles used on one page.
Alfman,
This was a larger discussion during the release of HTML 4.0 and XHTML.
In XML based XHTML, you have to close your tags. (In addition to strict lower case requirements and so on)
This included leaf nodes like image or line breaks. But there was a shortcut, you could just end the tag with a / like [ img / ] (@Thom still no TT or PRE in here)
For SGML based HTML 4.0 the spec explicitly allows skipping those, and also adds implicit closing tags between repeated items like paragraphs or list elements. And did not like self closing tags.
And HTML5 combined the two. You can now use those self closing tags in HTML as well.
But I get the call for disciplined closing of all. It is nice to have.
I started learning HTML before I entered college, and I never closed tags that didn’t explicitly require it because I learned by copying other people’s code, and they didn’t do it so I had no idea it was even a thing. This was the mid-late 90s mind you, I was fresh out of high school but delayed entering college because I was battling cancer at 18 years old; I had nothing else to do all day but browse the newfangled Web and learn how it was constructed.
Once I was able to go to college in 2001, I was ahead of the curve a bit thanks to my self-learning endeavors, but like any other academic environment I had to learn the “proper” way to write HTML code, which meant closing every paragraph and list and line break. My complaint was that my way worked just fine, the instructor’s response was if I learned it the “right” way I could get a job more easily, then once I had the job I could do it the way I wanted as long as it worked. Joke was on them, I pivoted from web development to networking and database management courses since that interested me more than making silly websites. Now I’m a sysadmin and I rarely have to touch HTML anymore, but when I do, I don’t close my damn tags unless I have to.
Now get off my lawn while I hang this onion from my belt and yell at that cloud over there. 😉
Morgan,
This probably doesn’t describe you, but from your narrative I am picturing a rebellious DB admin who carries a disregard for the “right way” from their HTML years into their SQL career. String concatenation everywhere instead of value parameters leading to SQL injection faults. Over rely on full page caches to mask bad query performance. Etc.
I take some pride in optimizing for high performance and it irks me whenever I see other software getting away with being so poorly optimized. I’m dealing with one right now and it’s atrocious! It must have been some punk HTML dev turned SQL admin. J/K 🙂
In truth I think corporate cheapness is responsible for making us rely more on faster hardware instead of software & database optimization. Many of us working at the companies know that these systems are faulty and sub-optimal but there’s constant pressure to do things on the quick and cheap. Giving a good DBA & coder enough time to build things right does make a big difference, but a “good“ project manager knows that the demo won’t exhibit these issues and leave it to be someone else’s problem on someone else’s dime. Haha.