Comment

Comment by kiwidrew

All of the examples provided are valid HTML5, and all HTML5-compliant user agents are required to implement the HTML5 parsing algorithm, which constructs a DOM tree in a deterministic manner for any given input.

HTML5 specifically permits tag omission in many cases [1], including but not limited to both the opening and closing <html>, <head>, and <body> tags. The parsing algorithm provided in the standard generates a DOM tree that includes the omitted tags in the correct place(s).

For example, the following document is valid HTML5:

  <!DOCTYPE html>
  <title>Hello</title>
  <p>Welcome to this example.

[1] https://www.w3.org/TR/html52/syntax.html#optional-tags
parent kiwidrew 6 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton