Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The page HTML is weird, there's no `<html>`, `<head>` or `<body>`.


None of those are needed for proper HTML; they're implicit.


> None of those are needed for proper HTML; they're implicit.

They are needed for proper HTML. They're just not needed for HTML.


They are not needed for proper HTML. <html>, <head> and <body> are all defined as having optional start tags and end tags. It’s perfectly valid and reasonable to skip their start tags if you’re not putting any attributes on them. (I always skip <head> and <body>, but never skip <html> because I always have a lang attribute on it, and sometimes more, such as a class attribute. But I definitely still skip its end tag.)

There’s plenty of precedent for habitually skipping start tags in the HTML syntax. Few people write <tbody> if they are doing a simple table with no <thead>, because <tbody>’s start and end tags are both optional. <html>, <head> and <body> are the same.

(I’m spelling out “in the HTML syntax” here, because if you’re using the XML syntax—not common, but not unknown—no start or end tags are optional; if you write <table><tr>…</tr></table> in an XML syntax HTML document, you will get an invalid HTML document that lacks the <tbody> element.)




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

Search: