What’s Needed in the Head of a HTML Document?

View List on GitHub

This post will take less than a minute to read.

It’s hard to remem­ber everything that should be included in the <head> of a HTML doc­u­ment. Old meta tags are some­times phased out and new meta tags are some­times intro­duced. The fact that noth­ing in the <head> ele­ment is actu­ally shown to your site’s visitors—with the excep­tion of the <title>—does­n’t help either.

As such, I’ve cre­ated a GitHub repos­it­ory to track what I per­son­ally view as import­ant inclu­sions in the <head> of a HTML doc­u­ment. Keep in mind that this is just a gen­er­ic start­ing point and that you may need to add or remove tags depend­ing on the project.

Do I even need the head element?

In HTML5 it’s actu­ally okay to omit the <head> ele­ment; the fol­low­ing will validate:

<!doctype html>
<title>Page Title</title>

With that being said, it is still best prac­tice to include both the <head> and <body> tags in a HTML document:

<!doctype html>
    <title>Page Title</title>

Tweet this