Reputation: 1399
As far as I've experimented closing tags that havent been opened dissapear and have 0 effect on the web, but i'd like to see an official documentation, Ill give an example:
<div>
Some content <a>some link</a><hr> </a>
</div>
The second "< /a>" as far as I can see just dissapears. I understand this is not a good practice and should be avoided, but i'd like to know if there is any official documentation about this situation.
Upvotes: 1
Views: 1201
Reputation: 40842
The html5 specification describes in detail how a parser should resolve parsing errors, like missing closing tags, wrong nesting, ... .
This description can be found here 8.2 Parsing HTML documents and in 8.2.5 Tree construction especially the 8.2.5.4.7 The "in body" insertion mode.
The relevant part regarding your </a>
is here:
The adoption agency algorithm, which takes as its only argument a token token for which the algorithm is being run, consists of the following steps:
Let subject be token’s tag name.
If the current node is an HTML element whose tag name is subject, and the current node is not in the list of active formatting elements, then pop the current node off the stack of open elements, and abort these steps.
Let outer loop counter be zero.
Outer loop: If outer loop counter is greater than or equal to eight, then abort these steps.
Increment outer loop counter by one.
Let formatting element be the last element in the list of active formatting elements that:
is between the end of the list and the last marker in the list, if any, or the start of the list otherwise, and
has the tag name subject.
If there is no such element, then abort these steps and instead act as described in the "any other end tag" entry above.
If formatting element is not in the stack of open elements, then this is a parse error; remove the element from the list, and abort these steps.
Upvotes: 4