HTML - The Head Element

The head> element in HTML is a container for metadata about the HTML content. It provides information that is not visible on the web page but is useful to browsers and search engines. Here are some examples of common items that can be used inside the head> element:

1. <title> :

The title of the HTML document is specified. This title is normally shown in the title bar or tab of the browser.

<head>
    <title>My Web Page</title>
</head>

2. <meta> :

Metadata regarding the HTML document is provided, such as character encoding, viewport settings, and a description.

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="A brief description of the web page">
</head>

3. <link> :

External resources, such as stylesheets (CSS) or icons, are linked.

<head>
    <link rel="stylesheet" type="text/css" href="styles.css">
    <link rel="icon" type="image/png" href="favicon.png">
</head>

4. <style> :

CSS rules that apply to the document are included.

<head>
    <style>
        body {
            font-family: Arial, sans-serif;
        }
    </style>
</head>

5. <script> :

JavaScript code or connections to external JavaScript files are present.

<head>
    <script src="script.js"></script>
</head>

6. <base> :

A base URL is specified for all relative URLs in the document.

<head>
    <base href="https://example.com/">
</head>

The <head>  element is an important section of an HTML page because it offers information that helps browsers correctly comprehend and render the content. While the text included within the <head> is not directly visible to visitors, it is critical to the overall operation and display of the web page.

Post a Comment

Previous Post Next Post

Popular Items