Lecture

head Tag

An HTML document defining a web page is divided into the following two parts:

  1. <head>: Provides information (metadata) about the webpage to search engines and browsers

  2. <body>: Defines the content to be displayed on the webpage

Content defined by the <head> tag is not visible on the web browser screen but includes meta information such as the title, description, keywords, and styles of a webpage.


Key Elements within the head Tag

1. title Element

Defines the title of the webpage. This title is displayed on the browser's tab.

Defining a Webpage Title
<head> <title>My First Webpage</title> </head>

2. meta Element

Defines metadata about the webpage for search engines.

For example, the meta tag can be used to set the webpage's character encoding (converting characters into a form that computers can use), viewport (the visible area of the webpage), description, and more.

Defining Metadata
<head> <!-- Character Encoding --> <meta charset="UTF-8" /> <!-- Page Description --> <meta name="description" content="Website Description" /> <!-- Initial scale and width of the viewport --> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> </head>

3. link Tag

Used to link an external resource to the webpage. Commonly used to import fonts or link stylesheets (CSS files defining the style of the webpage).

Linking External Resources
<link href="https://fonts.googleapis.com/css2?family=Open+Sans" rel="stylesheet" />

4. script Tag

Used to load JavaScript files or code, acting as the brain of the website.

JavaScript controls the behavior of the page (e.g., actions on button clicks).

Loading a JavaScript File
<head> <script src="script.js"></script> </head>

Lecture

AI Tutor

Publish

Design

Upload

Notes

Favorites

Help