Reputation: 3669
<!DOCTYPE html>
<meta charset="utf-8">
<body>
Hello, world!
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?
Upvotes: 8
Views: 1818
Reputation: 8027
The smallest HTML document for which the Nu Html Checker (the only HTML validator currently endorsed by the WHATWG) does not produce any errors nor warnings is the following:
<!DOCTYPE html>
<html lang="">
<title>x</title>
Upvotes: 0
Reputation: 96577
(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, thetitle
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>
Upvotes: 5
Reputation: 29959
The title tag can't be empty or only consist of whitespace. So if the document is in a context where the title tag is required, you will have to set a valid title value.
The title content model is defined as "Text that is not inter-element whitespace".
"Empty Text nodes and Text nodes consisting of just sequences of [space characters]" are inter-element whitespace. Space characters are space, tab, line feed, form feed and carriage return.
If the title tag is empty, the W3C Validator complains that "Element title must not be empty". The Validator is fine with only adding just spaces, even though that is not correct according to the specs.
It is valid if you add another non-space character:
<!DOCTYPE html>
<title>x</title>
You could use other space characters like non-break space or zero-width non-break space if you want to fake an "empty" title.
Upvotes: 3
Reputation: 47667
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>
Upvotes: 12