Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this minimalist HTML5 markup valid?

<!DOCTYPE html>
<meta charset="utf-8">
<body>
Hello, world!

SOURCE FOR CODE

If so, besides removing "Hello, world!" is there any tag that's able to be removed and it still be valid, and how do you know it's still valid?

like image 339
blunders Avatar asked Aug 13 '12 20:08

blunders


2 Answers

It's not valid. To check it you can run it in W3C Validator

The error is: Element head is missing a required instance of child element title.

...

UPDATE

As vcsjones stated the head element is optional. That's the title one is required. Credit to mootinator for pointing out that the body is also optional.

So the simplest valid document will be:

<!DOCTYPE html>
<title></title>
like image 141
Zoltan Toth Avatar answered Nov 18 '22 05:11

Zoltan Toth


(Assuming the HTML syntax of HTML5.)

Note that in some situations the title element is optional, too.

From HTML5’s definition of head:

The title element is a required child in most situations, but when a higher-level protocol provides title information, e.g. in the Subject line of an e-mail when HTML is used as an e-mail authoring format, the title element can be omitted.

So the minimal markup for a document that gets a title from a "higher-level protocol" is this:

<!DOCTYPE html>

If the document is the value of an iframe-srcdoc it’s this (assuming a title is provided by the container document):

<html>

And for a stand-alone document it’s this (the title element needs some actual content, as noted by kapep, so the "…" is just an example):

<!DOCTYPE html>
<title>…</title>
like image 5
unor Avatar answered Nov 18 '22 05:11

unor