Reputation: 792
I found that add attribute to close tag can treat as comment and is very convenient:
<div id="container">
very many mess that you may mess up tags....
</div container end>
And tested it on every browser and it seems no quirk.
I want to know does it has any side effect that I didn't notice?
Upvotes: 0
Views: 79
Reputation: 201568
In “genuine” XHTML, i.e. XHTML served with an XML content type, an attribute in an end tag is treated as a well-formedness error: the page is not displayed at all, and an error message is displayed instead.
Otherwise, there are no documented effects. The parsing rules in the current HTML5 CR imply that attributes in an end tag are parsed, but no processing (no meaning) is assigned to them. They are not specified as causing a parse error. This may, however, be an oversight; but declaring them as parse errors would just mean that browsers “may abort the parser” (and browsers do not actually do such things).
Thus, in HTML syntax (as opposite to XHTML syntax), attributes in end tags can be expected to be ignored. On the other hand, there is nothing particularly convenient about them. If you use </div container end>
, it may have undesired side effects on you or other humans that read the HTML source. You may get lured into thinking that this must be an end tag for <div id="container">
. It may, or it may not; this simply depends on whether it actually matches in the syntax – something that a good editor should show you.
Upvotes: 0
Reputation: 201439
It makes your html not valid anymore. It may have unexpected side effects, like forcing IE into "quirks" mode. Also, it seems abusive. Please just use HTML comments, <!-- Hello, World! -->
.
Upvotes: 3