The HTML <head> element stores details that help browsers and search engines understand a page, from its title and character set to stylesheet links and viewport settings. These details don’t appear as page content, but they shape how the page loads and displays—quiet work with a real impact.

Multiple Choice

What is the purpose of the <head> tag in an HTML document?

The purpose of the <head> tag in an HTML document is to contain metadata about the document. Metadata is information that describes various aspects of the document that is not visible to the user when the page is rendered in the browser. This includes elements like the document title, character set, links to stylesheets, scripts, and other meta tags that define viewport settings, keywords, author details, and more. By using the <head> tag, developers can configure how the document behaves and appears without displaying that content directly to users. For example, a <title> element within the <head> provides the title that appears in the browser tab, while <link> tags can connect to external CSS stylesheets to style the document. Other options like containing the main content, including CSS only, or creating interactive scripts do not accurately represent the role of the <head> tag. The main content of the document belongs in the <body> tag, while CSS is typically linked in the <head> tag but is not the sole purpose of it. Similarly, interactive scripts generally utilize the <script> tag which is also often included in the <head> but is not its exclusive purpose.

Every web page has two kinds of information: the content people see and the details that help browsers and other services handle that content. The <head> element holds many of those details. It sits near the top of an HTML document, before the visible page content, and acts like a small control room for the page.

That role can sound modest, but the head affects how a page is titled, displayed on different screens, styled, and understood by search engines. It doesn’t hold the main text, images, or buttons visitors come to see. Instead, it carries instructions and descriptions that shape how the page works.

What belongs in the head?

A basic HTML document has a familiar structure:


<!doctype html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>Garden Notes</title>

</head>

<body>

<h1>Welcome to Garden Notes</h1>

<p>Ideas for growing a little more green.</p>

</body>

</html>

The <head> element appears inside <html> and before <body>. The browser reads information in the head as it processes the page. Most of that information doesn’t appear in the page itself. The <title> is a useful exception: it usually shows in the browser tab, even though it isn’t displayed as a heading in the page.

The distinction is simple: the <body> contains the content visitors read or interact with; the <head> describes the document and connects it to resources it needs. Think of a book. The body is the story, while the head is more like the title, language note, and production details that help people identify and present it.

Metadata: information about the page

Metadata is information that describes a document rather than forming its visible content. In HTML, metadata can tell the browser what character encoding to use, describe the page, set display behavior for mobile devices, or provide a title.

One important example is the character set declaration:


<meta charset="UTF-8">

UTF-8 supports a broad range of characters and symbols, including accents and many writing systems. Without a suitable encoding, text may appear as odd symbols or replacement marks. That’s a small detail with a very visible effect: a page can be beautifully designed and still look broken if its text is decoded incorrectly.

Another common element is a description:


<meta name="description" content="Simple ideas for growing herbs at home.">

This gives a short summary of the page. Search services may use it when presenting a result, though they can choose different text if another snippet better matches a search. It doesn’t guarantee a particular ranking or display. Its purpose is to describe the page clearly.

The language of the document is often set on the <html> element, not inside <head>:


<html lang="en">

That detail helps screen readers and other tools interpret the content. It’s a good reminder that HTML elements each have a defined job; similar-looking bits of information don’t always belong in the same place.

Titles, stylesheets, and other connections

The <title> element gives the document a concise name:


<title>Growing Herbs Indoors | Garden Notes</title>

This title typically appears in the browser tab, browser history, and saved bookmarks. A clear title can also help people understand a search result before they open it. It should describe the page, not simply repeat a site name or pile up keywords.

The head is also where a page commonly links to an external CSS file:


<link rel="stylesheet" href="styles.css">

This doesn’t mean the head exists only for CSS. The link connects the HTML document to a stylesheet, which controls visual presentation such as color, spacing, and layout. Keeping styles in a separate file can make a site easier to maintain: one stylesheet may guide many pages, much like a shared set of design notes.

A page may also include a small amount of CSS in a <style> element inside the head:


<style>

body {

font-family: Arial, sans-serif;

}

</style>

That’s valid, but it doesn’t make the head a CSS-only area. It can contain several kinds of information and links, each serving a different purpose.

JavaScript can be connected here as well, using a <script> element. But scripts aren’t what define the head’s job. A script may load in the head, in the body, or through other loading approaches, depending on what it needs to do and when it should run. The key point is that the head is a place for document-level information and resources—not a special container for one kind of code.

Helping pages behave on small screens

Many pages include a viewport declaration:


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

This tells mobile browsers how to set the page’s visible width and initial scale. Without it, a phone may treat the page as if it were much wider than the screen, then shrink the whole layout to fit. The result can be tiny text and awkward navigation.

The viewport setting works alongside responsive CSS. It doesn’t create a mobile layout by itself; instead, it gives the browser useful information so the layout can respond as intended. This is a good example of how HTML and CSS share the work. HTML describes structure and document information, while CSS shapes the page’s presentation.

What doesn’t belong there?

The main content of a page belongs in <body>, not <head>. Headings, paragraphs, images, menus, and forms are visible or interactive page content, so they should be placed in the body.

For example:


<body>

<h1>Growing basil</h1>

<p>Basil grows well in a bright spot with regular watering.</p>

</body>

Putting visible content inside the head is a structural mistake. Browsers may try to recover from invalid markup, but relying on that recovery can lead to confusing results. Good structure makes a document easier for browsers, assistive technology, and other developers to understand.

The head also isn’t limited to metadata in the narrow sense. It can contain resource links and scripts, too. That’s why “information about the document” is a useful big-picture description: the head helps describe the page and prepare the browser to handle it, while the body carries the page’s visible substance.

A few details worth remembering

HTML allows some elements in the head and not others. Common contents include <title>, <meta>, <link>, <style>, and <script>. Their order can matter in a few cases. For example, placing the character encoding declaration early helps the browser interpret the document correctly from the start.

The head itself isn’t shown as a box on the page. It doesn’t create a visible section or add spacing around the content. Its effects are often indirect: a browser tab gets its label, a stylesheet sets the page’s look, or a mobile browser handles the viewport more sensibly.

That quiet work is easy to overlook. Yet a well-formed head gives the browser the context it needs before someone reads the first heading. It’s a small part of an HTML file, but it helps connect content, presentation, and document information into one coherent page.