Hacker News new | past | comments | ask | show | jobs | submit login

I tried the SuperHTML on a hand-coded site of mine and it reported only one problem and that problem is incorrect as far as I can tell. It tells me that the `</html>` tag is never opened on an HTML 5 doc with a `<!DOCTYPE html>` opening tag. The author does say it's not perfect and I probably need to double-check my understanding just to be sure. In any case, it seems like a useful thing and I am also surprised I never thought it was missing.

For those who are like me and don't know the term, "a language server for HTML" is referring to the plugin that evaluates your HTML syntax. That might be a narrow explanation of the tool but that's the basic idea I got from trying it.




`<!DOCTYPE html>` is not an html opening tag. It is a preamble.

https://html.spec.whatwg.org/multipage/syntax.html#writing


`<!DOCTYPE html>` is not paired with `</html>`. This is what the basic HTML5 boilerplate looks like:

   <!DOCTYPE html>
   <html>
     <!-- content goes here -->
   </html>


If it complains about an unmatched </html>, that's fine. But you can omit <html> as it is an implied tag: https://html.spec.whatwg.org/multipage/semantics.html#the-ht...

> An html element's start tag can be omitted if the first thing inside the html element is not a comment.

> An html element's end tag can be omitted if the html element is not immediately followed by a comment.

The only explicit tag that is required for every HTML document is <title>, which you supposed boilerplate misses.


According to the specs the <html> tag can be fully omitted. From MDN [1]:

> The start tag may be omitted if the first thing inside the <html> element is not a comment.

> The end tag may be omitted if the <html> element is not immediately followed by a comment.

1: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ht...


I knew that that the <html> tag can be fully omitted (and some others, like <body> and <title> IIRC), but if I read that it can also be partially omitted. So you're allowed to open it but not close it, or close it but don't open it. That's new to me.

I've tried omitting those tags, but I decided that in the end things are easier to read when you do include them, so nowadays I always include them when I write HTML.


SuperHTML README says:

> This language server is stricter than the HTML spec whenever it would prevent potential human errors from being reported.

If your goal is to output minimal HTML, let a tool automate that. Forgetting to open <html> is more likely a mistake than shorthand, and as shorthand it's not valuable.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: