Skip to content

Instantly share code, notes, and snippets.

@j9t
Last active December 9, 2019 22:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j9t/fa19e217a1188e200547 to your computer and use it in GitHub Desktop.
Save j9t/fa19e217a1188e200547 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<title>␣</title>
@thierryk
Copy link

You are missing <!-- TADA! -->

@j9t
Copy link
Author

j9t commented Aug 17, 2014

Oops. :)

@wooorm
Copy link

wooorm commented Sep 11, 2019

@j9t There is a shorter version (if we’re allowing parse errors, which user agents do)! You don’t need the space between DOCTYPE and html! https://html.spec.whatwg.org/multipage/parsing.html#doctype-state

<!DOCTYPEhtml>
<title></title>

@j9t
Copy link
Author

j9t commented Sep 17, 2019

@wooorm, interesting! Yet I read the spec that there must be either of U+0009, U+000A, U+000C, or U+0020, and not no character to proceed. Which would be backed by validation of the snippet. Although a version without a space would be shorter (and likewise one without a line break between DOCTYPE and title, I might for once vote for leaving those characters :)

@wooorm
Copy link

wooorm commented Sep 18, 2019

Right, that is reasonable! 👍 To clarify: yes, it is a parse error, which conformance checkers like the validator should report, but parse errors are well defined in the HTML spec (e.g., <div id=a id=b> is a parse error, but works the same in browsers following the spec)

@meduzen
Copy link

meduzen commented Dec 9, 2019

Also, gzipped doctype saves 2 bytes over DOCTYPE. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment