The HTML <head> element is a container for metadata. It contains information about the webpage such as title, styles, scripts, links and meta tags.
The HTML <head> element is placed between the <html> and <body> tags. It stores information about the webpage.
<html> <head> ... </head> <body> ... </body> </html>
Metadata may include:
The <title> element defines the title of the webpage.
<title> My Website </title>
The title:
The <meta> element provides information about the webpage.
<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
Meta tags are used for:
The <style> element is used to define internal CSS.
<style>
body{
background:lightblue;
}
h1{
color:red;
}
</style>
Internal CSS styles a single webpage.
The <link> element connects external resources.
<link rel="stylesheet" href="style.css"> <link rel="icon" href="favicon.ico">
The HTML <script> element is used to add JavaScript to a webpage.
<script>
alert("Welcome");
</script>
JavaScript can:
The HTML <base> element specifies the base URL for all relative URLs.
<base href="https://example.com/" target="_blank">
Important points:
The viewport is the visible area of a webpage.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
| Element | Purpose |
|---|---|
| title | Page title |
| meta | Metadata |
| style | Internal CSS |
| link | External resources |
| script | JavaScript |
| base | Base URL |
Which HTML element defines the title of a webpage?