The minimal code required in a HTML5 page
dev.chetankjain.net
dev.chetankjain.net
The important fact is that omitting the html, body, head tags is valid markup. Whether browsers conform to this is another matter. [1] suggests there are some issues with that.
[1] http://stackoverflow.com/questions/5641997/is-it-necessary-t...
All other major browsers have already switched to an HTML5 parser
* Firefox since Firefox 4: http://hacks.mozilla.org/2010/05/firefox-4-the-html5-parser-...
* Webkit since ~early 2011: http://www.webkit.org/blog/1273/the-html5-parsing-algorithm/ I don't have the exact dates for stable versions of Chrome and Safari
* Opera since December 2011: http://www.opera.com/docs/changelogs/windows/1160/
[0] "html5 parser" is used as a shortcut for "parser implementing the HTML5 parsing algorithm"
The point of the post is that the syntax for writing html is getting better (just using 'html' as a doctype is great). But in terms of application, there is none.
If you want to write a web site/service and you want to support more users than just your friends, you have to do things right to support older browsers (and IE) and this means things like including all of the tags that FF/Chrome are automatically adding.
If you're talking about the minimal valid code for an independent web page, it is:
<!DOCTYPE html><title></title>
The title element is required, and is not automatically inserted if the tags are missing the way <html>, <head>, and <body> are.If you're talking about the minimal thing the browser will parse, you can provide an empty document (with Content-type: text/html), and the browser will treat it as if it's an HTML document, generating the appropriate elements automatically. It will parse it in quirks mode, but if you don't care about validity, and are talking about an empty document, that doesn't matter much.
If you're talking about what you can embed in <iframe srcdoc>, again, an empty document is acceptable. In that context, the doctype and title are both optional.
<!DOCTYPE html>0
would be the smallest.
<title//x
This uses the never-implemented but legal shorttag syntax for the required title element, and the "x" character serves as the body content.HTML parsers cope quite well with that (and have done for a while) but I don't do it. Although I am guilty of not bothering with the type declaration in scripts that are JavaScript <script src="..." />
I know I'm just plain lazy and wrong.