Skip to content

Instantly share code, notes, and snippets.

@cmalven
Last active April 27, 2024 10:17
Show Gist options
  • Star 53 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save cmalven/1885287 to your computer and use it in GitHub Desktop.
Save cmalven/1885287 to your computer and use it in GitHub Desktop.
Shortest (useful) HTML5 Document
<!-- http://www.brucelawson.co.uk/2010/a-minimal-html5-document/ -->
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>blah</title>
</head>
<body>
<p>I'm the content</p>
</body>
</html>
@alemens
Copy link

alemens commented Oct 24, 2022

Why does everyone include <meta charset="utf-8">?

UTF-8 is the only valid encoding for HTML5 documents. Means if you have <!DOCTYPE html> at the top of an HTML file then charset is implied

@punund
Copy link

punund commented Sep 15, 2023

if we're talking about a minimal HTML document, it's certainly not required - but doesn't really seem like a good idea either way.

Now imagine serving files with different encodings off the same web server.
Encoding is inalienable from the document itself. You can't usefully change the encoding without changing the text.

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