HTML5 Closing tags

I understand that HTML5 does not require closing of tags.

Will/do you omit closing tags when/if you develop with HTML5? Or will you continue to close all tags?

HTML5 has the same option of omitting closing tags as HTML4 - and the same list of tags that are not allowed to have a closing tag.

XHTML5 requires all tags to be closed just the same as any other XML file does…

I’ll continue to use closing tags, as it seems really sloppy not to. Apart from anything, it makes the code easier to read to see where things end.

I’ll continue to not use closing tags. They are wasted bytes the browser has to look at before deciding to ignore.

However what I wish is that people using HTML5 would be consistent. If you want to write HTML5 like XHTML, fine, but what people are doing is mixing and matching. They’ll do
<!doctype html>
<meta charset=“utf-8”>
<title>blah blah</title>
<meta name=“description” content=“some content” />

Seriously, this doesn’t make code look neater, it follows no rules, and you’re not saving anything. A sure way to make any mildly pathologic OCD front-end coder to go nuts and you’ll start finding Fresh Whole Rabbits from Amazon in the company fridge on odd days.
With faces drawn on them with magic marker.

You see that quite a lot, people mixing self-closing element slashes (but also minimising or dropping attributes, etc.) on an HTML5 page, which is pretty stupid, i.e. mix-and-matching on the same page. Unless you are intending to write XHTML5 that obviously requires self-closing for EMPTY.

It indicates the author doesn’t seem to know what they want and cannot decide which side of the fence they sit upon, if they must write HTML5 (text/html) then observe it’s bad practice to do <element /> whereas if they choose XHTML5 (application/xhtml+xml) it is apt.

Or a better suggest still, perhaps they should use something fully normative instead of pretending they are awesome by abusing a markup language regardless.

When talking about closing tags, I meant this:

<li>Blah blah blahdy blah</li>

Not closing slash. That’s something I’d never use.

Dunno if I’m misunderstanding the OP, but that’s what I thought this thread was about.

To be honest it [Post #1] could mean generically either (and probably does) but I get the impression it was mainly implying self-closing elements; since HTML 4.01 Strict already allows you to omit end tags in some cases and that’s going to be potentially carried over to Fred ‘text/html’.

Dunno if I’m misunderstanding the OP, but that’s what I thought this thread was about.

Ah. It didn’t occur to me that some people do rely on browsers to fill in missing tags.

Though I do know someone who does it on purpose. He says he’s serving fewer bytes, but doesn’t reckon with the browser needing to spend whatever nano-seconds it needs to build a proper DOM by adding stuff. Actually I wonder who’s got a measurer sharp enough to measure the difference.

Just because the standard that the browsers are supposed to follow says that they need to allow for someone forgetting to put certain tags in and that the browser should therefore GUESS where those missing tags are supposed to go doesn’t mean that the standard those creating web pages should follow should allow it. The problem is that there is a standard for the browsers to follow but those writing web pages are left to write their own standard and most don’t know what standards are.

The time cost in leaving out tags is the extra time spent in maintaining pages. Whether the page loads faster because the file is smaller or loads slower because it has to work out where to insert the missing tags is irrelevant when considering the weeks or months that might be wasted becausethe page doesn’t render as you expect due to omitted tags being inserted somewhere different from where you thought they ought to go (as compared to if you put them in the validator would immediately point out the error).

Good man.

Well, we are talking HTML 5, which is a bunch of stupid idiotic bull for even ALLOWING the mixing and matching, which is why as a specification on the whole it seems carefully crafted for the people who before 5 became trendy were just vomiting up HTML 3.2 and slapping a tranny doctype on it… the same people who slap div around elements for not good reason now get to slap allegedly semantic tags around existing semantic tags for no good reason – and on the whole sets coding practices BACK to 1997.

Which is why I still say “Just say no” to HTML5… and still can’t believe ANYONE is DUMB ENOUGH to see much if any merit in the core markup part of it – again why they had to slap all the other stuff like the new .js and CSS3 under it’s banner, since without those it’s like an old Wendy’s commercial… they put a very big fluffy bun around it:


Hey it’s about TIME they gave us getElementsByClassName(). Christ, that waited about a decade too long.

Meh, the fact that you don’t have to follow any particular style in HTML5 is precisely because… you really didn’t have to with anything else, unless you really really really REALLY were serving REAL XHTML. But you weren’t, we weren’t, nobody was, everyone wrote whatever and the browsers knew how to just DWIM.

So the HTML5 spec says, since that’s the case, fine. Leave it. The only people who would even bother reading new rules about quoted attributes and closing slashes are the only people actually practicing it anyway. Those who never did, never will. One of the goals of HTML5 was to document what browsers actually gave a rat’s about.

Though the funny thing abotu quoting your attributes is, it’s way lazier and easier to just do it all the time. Your other option is to memorise all the edge cases where it breaks s. everywhere.
If you’re not quotin’ yer attributes, you must be bored and lookin’ for sumthin’ to do.

Most people will just continue building messy unmaintainable web pages regardless of what the standards say.

Ignoring all the non-HTML things that people are trying to label as a part of HTML 5 there are still a couple of additions that are worthwhile. The require and pattern attributres are one example of something useful. Even if no browser were to ever support those attributes they remove most of the complexity in being able to do JavaScript frm validations. Those who don’t know JavaScript will be able to copy and paste a script that will require only minor changes to be able to validate any form.

I have another question about closing tags. I’d like to use them to self-document where the div ends. That is, on a really long div, or nested divs or other tags, which can get confusing, something like:

<div id=‘bigFrigginDiv’>
Lots of stuff…
</div nm=‘bigFrigginDiv’>

Will this work? Will it break anything? It appears to work but will it cause future problems. Do I even need the nm or the quotes, or should I use a legal var, like id? I know you can use HTML comments, but they’re a pain, and this is faster.

Really? Nah, use comments. I’ve never seen code inside a closing div tag. Browsers may overlook it, but I’d say don’t risk it.