The HTML `<head>` tag is a crucial element of a website and can be found at the top of each page, right inside the opening `` tag. The HTML `<head>` tag’s purpose is to provide additional information about the web page.
Inside the `<head>` tag, there are several other HTML tags you can use, each serving a unique purpose. Tags like `<title>`, which defines the title shown in the browser’s title bar or tabs; `<style>` for embedding CSS styles; and `<meta>` tags for providing metadata about the HTML document. You can also use `<link>` to link external resources like CSS files, and `<script>` to link JavaScript files or write inline JavaScript. It’s important to note that the contents of the `<head>` tag are not rendered on the web page, instead, they provide information to the browser and the search engines.
Here is a basic example of how the `<head>` tag is used in an HTML document:
<!DOCTYPE html>
<html>
<head>
<title>My First Web Page</title>
<meta charset="UTF-8">
<meta name="description" content="This is a description of my first web page">
<link rel="stylesheet" type="text/css" href="styles.css">
<script src="script.js"></script>
</head>
<body>
<!-- The visible part of your HTML page goes here -->
</body>
</html>
In this example, we see the `<head>` tag containing several other tags. The `<title>` tag sets the title of the web page, which is displayed in the browser tab. The `<meta>` tags set the character encoding for the page and describe the page. The `<link>` tag links to an external CSS file, and the `<script>` tag links to an external JavaScript file. Remember, as I already mentioned, none of these elements will be visible on the rendered page; they are only there to provide information to the web browser and search engines.
That’s it for our quick explanation of the HTML `<head>` tag. I hope this helps you to understand what the `<head>` tag is and how it can be used in an HTML document. As always, happy coding! Don’t forget to subscribe for more web development videos and full courses to boost your income to over $50,000 a year!
Comments (76)