<head> Tag in HTML
The <head> tag in HTML is used to contain metadata and links to external files that are required for the document, such as stylesheets, scripts, and fonts. The <head> section does not display content directly on the webpage but provides essential information about the document to the browser and search engines.
Key Points on <head> Tag:
- The <head> tag is placed before the <body> tag in an HTML document.
- It contains metadata like title, meta tags, link tags for stylesheets, and script tags for external JavaScript files.
- The contents inside the <head> tag are not displayed on the web page itself but help in controlling the presentation and functionality of the webpage.
Syntax of <head> Tag:
Syntax Example
<head>
<meta charset="UTF-8">
<title>Page Title</title>
<link rel="stylesheet" href="styles.css">
<script src="script.js"></script>
</head>
Example of <head> Tag in HTML:
This example demonstrates the use of the <head> tag to include a title, a stylesheet, and a script.
Code Example
<html>
<head>
<meta charset="UTF-8">
<title>My Web Page</title>
<link rel="stylesheet" href="style.css">
<script src="app.js"></script>
</head>
<body>
</body>
</html>
Output
The <head> tag is essential for providing meta-information about the document. The <title> tag inside the <head> tag sets the title of the page, which appears in the browser's title bar or tab. The <meta> tag provides metadata about the document, such as the character set. External resources like stylesheets and scripts are also linked within the <head> section.