Skip to main content

What is the <head> element in HTML?

The <head> element in HTML is a service (invisible) part of the document that contains metadata about the page: its title, encoding, linked styles, scripts, a description for search engines, and more.

The browser uses the contents of <head> to understand how to process and render the page, but does not show it to the user.


1. Where <head> is located

It is located between the tags <html> and <body>, and always comes before the page's main content.

Example of a basic structure:

html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>My site</title> <link rel="stylesheet" href="style.css"> </head> <body> <h1>Hello, world!</h1> </body> </html>

2. What is stored inside <head>

<head> contains technical tags that control the page's behavior but do not output content.

TagPurpose
<title>Page title (shown on the browser tab)
<meta charset="UTF-8">Sets the text encoding
<meta name="description" content="Page description">Description for search engines (SEO)
<meta name="viewport" content="width=device-width, initial-scale=1.0">Adapts the page for mobile devices
<link rel="stylesheet" href="style.css">Links an external CSS file
<script src="script.js" defer></script>Links a JavaScript file
<style>Inline CSS rules
<base href="/">Sets the base path for links
<meta name="keywords" content="html, css, web">(deprecated) keywords for SEO
<meta name="author" content="Author name">Page author
<link rel="icon" href="favicon.ico">Site icon shown on the browser tab

3. The role of <head> for the browser and search engines

  • reports the page's key technical parameters (encoding, language, responsiveness);
  • provides meta descriptions for SEO and social networks;
  • links external resources: styles, scripts, icons;
  • helps the browser optimize loading and indexing of the site.

Summary:

CharacteristicDescription
LocationBetween <html> and <body>
PurposeContains metadata and service information
Displayed on the pageNo
Main tags<title>, <meta>, <link>, <script>, <style>
ImportanceCritical for SEO, encoding, and linking resources

In simple terms: The <head> is the web page's "passport." It is not visible to the user, but it tells the browser who it is, what it is, what language it is written in, and where to get everything needed to render the page.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.