Last active
July 17, 2021 21:30
-
-
Save treyharris/3c521e16f2232c9d49e7a04fcacdfc02 to your computer and use it in GitHub Desktop.
Revisions
-
treyharris revised this gist
Jul 17, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ # In search of the shortest HTML5 document I was curious what wass the minimum-allowed HTML5 document. I _think_ it is (neglecting newlines and indention whitespace, which are deleted to make the document shorter in character length): ```html <!doctype html> -
treyharris revised this gist
Jul 17, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -55,7 +55,7 @@ you can leave out the `=…` when an attribute is empty. So, we can kill the `=" </title> ``` or, removing whitespace, we get these 42 characters: ```html <!doctype html><html lang><title>.</title> -
treyharris created this gist
Jul 17, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,64 @@ # In search of the shortest HTML5 document I was curious what wass the minimum-allowed HTML5 document. I _think_ it is (neglecting newlines and indention whitespace, which could be deleted to make the document shorter in character length: ```html <!doctype html> <html lang> <title> . </title> ``` With the `.` replaceable by almost any plaintext character. If you don't care about warnings, this works: ```html <!doctype html><title>.</title> ``` however, the [HTML5 validator](https://validator.w3.org/) suggests: > Consider adding a `lang` attribute to the `html` start tag to declare the language of this document. To remove the warning, you could write something like: ```html <!doctype html> <html lang="en"> <title> . </title> ``` Since all allowed `lang` subtypes have at least two characters, there's no language shorter than `en` (or `de` or `fr` or `ja`, etc.). However, an _empty_ `lang`: ```html <!doctype html> <html lang=""> <title> . </title> ``` is allowable, and does not even cause warnings. By [the spec](https://html.spec.whatwg.org/multipage/syntax.html#attributes-2), you can leave out the `=…` when an attribute is empty. So, we can kill the `=""` part, which gives us ```html <!doctype html> <html lang> <title> . </title> ``` or, removing whitespace, ```html <!doctype html><html lang><title>.</title> ``` Is there a shorter one (that is actually HTML5, validates without warnings on the [HTML5 validator](https://validator.w3.org/), and doesn't "cheat" by messing with doctypes or comments)? Comment below! This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ <!doctype html> <html lang> <title> . </title> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ <!doctype html><html lang><title>.</title> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ <!doctype html><title>.</title>