Re: Self closing tag error message

> On Sep 29, 2022, at 2:41 PM, Jukka K. Korpela <jukkakk@gmail.com> wrote:
> 
> Is there a rationale for this? The “self-closing” syntax like <br/> looks perfectly harmless to me. Of course, it’s a holdover from the era when “XHTML” was popular without any good reason, but in non-XML parsing <br/> has always been read as <br>.

The main rationale seems to be that self-closing syntax interacts badly with optional attribute quoting. For example, the following causes confusion: 

<link rel=stylesheet href=/styles.css/>

Through XML-colored glasses, it may looks like it should load "/styles.css", but browsers will try to load "/styles.css/" and get a 404.

I think that self-closing tags have always been an error in HTML. The error was flagged by the HTML 2-4 validators, so this change just brings the HTML 5+ validator back in line.

- Chuck

Received on Monday, 3 October 2022 16:18:18 UTC