<head>: The 'head' element - Best Practices

The Bare Minimum

Below are the essential elements for any web page/app.

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Example: 'head' element - Best Practices</title>

Always declare the encoding of your document using a meta element with a charset attribute, or using the http-equiv and content attributes (called a pragma directive). The declaration should fit completely within the first 1024 bytes at the start of the file, so it's best to put it immediately after the opening head tag. W3C - Declaring character encodings in HTML

Every HTML document must have a TITLE element in the HEAD section. W3C - HTML 4.01 Specification

No Scripting

If your web page/app depends on scripting at all, opt for graceful degredation in the first instance or redirect the user to a fallback page.

<noscript> <meta http-equiv="refresh" content="0;url=noscript.html" /> </noscript>

The 'noscript' element allows authors to provide alternate content when a script is not executed. W3C - HTML 4.01 Specification

Responsive Web Design

<meta name="viewport" content="width=device-width, initial-scale=1" />

You should include the <meta> viewport element in all your web pages W3Schools - Responsive Web Design - The Viewport

The HTML5 Shiv

HTML 5 was initially released in 2008. Web browsers released before that date don't recognise HTML5 elements out-of-the-box. Most web browsers render unknown elements as block elements which results in many of the new elements being rendered correctly. Unfortunately, this lack of support extends to JavaScript where you are unable to use query selectors for unknown elements.

<!--[if lt IE 9]> <script src="https://github.com/aFarkas/html5shiv/tree/master/dist/html5shiv.js"></script> <![endif]-->

CSS3 Custom Properties for Internet Explorer 11

Internet Explorer 11 supports the majority of the CSS3 specification but lacks support for Custom Properties.

<script>window.MSInputMethodContext && document.documentMode && document.write('<script src="https://github.com/nuxodin/ie11CustomProperties/ie11CustomProperties.min.js"><\/script>');</script>