head Tag
An HTML document that defines a webpage is divided into two elements as shown below:
-
<head>
: Provides metadata information about the webpage to search engines and browsers -
<body>
: Defines the content to be displayed on the webpage
The content defined within the <head>
element of an HTML document includes meta information such as the title, description, keywords, and style of the webpage.
Key Elements in the head Tag
While the head tag can contain various pieces of information about a webpage, the elements used most frequently are the ones listed below.
title Element
Defines the title
of the webpage. This title is displayed on the browser tab.
<head> <title>My First Webpage</title> </head>
meta Element
Defines metadata
(information about the webpage) that is displayed to search engines.
For example, the <meta>
tag can be used to set the character encoding of the webpage (converting characters into a format that computers can use), viewport (the area of the webpage visible to the user), and page description.
<head> <!-- Character encoding --> <meta charset="UTF-8" /> <!-- Page description --> <meta name="description" content="Description of the website" /> <!-- Initial scale and width of the viewport --> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> </head>
link Tag
Used to associate the webpage with external resources
.
Commonly used to load fonts or link to stylesheets (CSS files that define the style of the webpage).
<link href="https://fonts.googleapis.com/css2?family=Roboto" rel="stylesheet" />
script Tag
Used to load JavaScript files or code
, which serve as the brain of the website.
JavaScript controls the behavior of the page (e.g., actions when a button is clicked).
<head> <script src="script.js"></script> </head>
The <head>
tag is used to signify the start of an HTML document.
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help