This HTML is valid because HTML 4.01 allows these things, and an internet browser that respects doctype will display this without a problem.
If you change doctype to HTML 5, this will definitely give an error, since HTML 5 is more strict in writing a proper HTML tag.
HTML 4.01 (no error according to https://validator.w3.org/#validate_by_input ):
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html<head> <title// <p ltr<span id=p></span</p> </>
HTML 5 (15 errors according to https://validator.w3.org/#validate_by_input ):
<!DOCTYPE html> <html<head> <title// <p ltr<span id=p></span</p> </>
Explanation:
This HTML structure is valid because according to the HTML 4.0.1 specification ( https://www.w3.org/TR/1999/REC-html401-19991224/ ):
B.3.7 Abbreviated markup
Some SGML SHORTTAG constructs retain text input but do not add expressive capabilities to an SGML application. Although these constructs do not technically allow ambiguity, they reduce the reliability of documents, especially when the language is improved to include new elements. Thus, although SHORTTAG SGML constructions associated with attributes are widely used and implemented, those associated with elements are not. The documents that use them conform to SGML documents, but are unlikely to work with many existing HTML tools.
The SHORTTAG constructs in question are as follows:
- NET tags:
<name/.../ - closed Start tag:
<name1<name2> - Empty start tag:
<> - The tag is empty:
</>
Quote from https://www.w3.org/TR/1999/REC-html401-19991224/appendix/notes.html#hB.3.7 .
So, based on this HTML 4.01 specification, this means:
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> 2 <html<head> 3 <title
- Line 1 is a valid doctype for HTML 4.0.1.
- Line 2 is a valid
<html> open tag; closing the tag </html> not required. - Line 2 is also a valid
<head> open tag; closing the </head> not required. - Line 3 is a valid
<title> , which the Internet browser reads <title// <p ltr<span id=p> just like <title> , closing the </title> not required. - Line 4-5 is the content (internal HTML) of the
<title> , which is </span</p> </> (this is what the Internet browser displays as the page title).
This was my additional explanation. Hope this helps you.