Skip to main content

HTML Tags

HTML <head> Tag

Written by Updated HTML <head> Tag exercises

The head tag is the part of the page the reader never sees: the title for the browser tab, the character set, the CSS and scripts to load, and descriptions for search engines. It sits between html and body.

Syntax

html

<head>
  <!-- Metadata and external resources go here -->
</head>

Example

html

<!DOCTYPE html>
<html lang="en">
<head>
  <title>HTML Head Example</title>
  <meta charset="UTF-8">
  <meta name="description" content="An example of using the head tag in HTML.">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="/samples/example.css">
</head>
<body>
  <h1>Welcome!</h1>
  <p>This page uses metadata and linked CSS inside the <head> section.</p>
</body>
</html>

On the page, you see "Welcome!" and a paragraph. Everything in the <head>, such as the title "HTML Head Example", is not displayed in the page itself; the title shows in the browser tab.

What goes inside

  • <title>: the page name. Required, exactly one.
  • <meta>: information like the character set, viewport and description.
  • <link>: stylesheets, icons and other connected files.
  • <style>: CSS written in the page.
  • <script>: JavaScript, usually with defer.
  • <base>: the base address for relative links, rarely needed.

Each of these is explained in HTML Head Element Tags.

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

Good to know

  • One <head> per page, before <body>.
  • If you leave the tags out, the browser still creates a head and body for you, but write them anyway for clarity.
  • Search engines and social sites read the head first, so a good title and description directly affect how your page appears in results and shares.

HTML <head> Tag exercises

Describe the page in its head

Write a page with a head that holds the title HTML notes and a description meta tag that says: Short notes on HTML. In the body put the paragraph Start here.

Result

Check your answer to see it here.