Recommended minimum HTML head

Webdev, HTML, Browser · Jan 18, 2023

An essential part of an HTML document is the <head> element, which contains metadata about the document. Some vital information, such as the document's title and character encoding are stored in the <head> element. It's also where you can include links to external resources such as CSS stylesheets and JavaScript files.

More often than not, this sort of metadata can grow in complexity with time. However, there are a few important things that should never be omitted. Here's a list of the bare minimum you should include in your <head> element:

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Page Title</title>
  <meta name="description" content="Page description. No longer than 155 characters.">
  • The charset meta tag tells the browser what character encoding to use when rendering the document.
  • The viewport meta tag tells the browser how to render the page on mobile devices.
  • The title element is used by search engines to display the page's title in search results.
  • The description meta tag is used by search engines to display a short description of the page in search results.

Written by Angelos Chalaris

I'm Angelos Chalaris, a JavaScript software engineer, based in Athens, Greece. The best snippets from my coding adventures are published here to help others learn to code.

If you want to keep in touch, follow me on GitHub or Twitter.

More like this

  • HTML Head Basics

    Learn how to use the HTML head element to improve your site's SEO, social sharing, and user experience.

    Collection · 4 snippets

  • Recommended HTML head icon tags

    Ensure your HTML documents have a proper favicon by including these lines in your <head> element.

    HTML, Webdev · Jan 24, 2023

  • Recommended social tags for HTML head

    Ensure your HTML documents can be shared on social media by including these lines in your <head> element.

    HTML, Webdev · Jan 22, 2023

  • Recommended HTML head links

    Make your HTML documents more SEO-friendly by including these lines in your <head> element.

    HTML, Webdev · Jan 26, 2023