HTML head element is a container that encloses metadata and other non-visible elements related to the HTML document. It provides information about the document but does not contribute to the visible content of the webpage.

The <head> element is placed within the <html> element and comes before the <body> element. It typically contains elements such as:

  1. <title>: Specifies the title of the webpage, which appears in the browser's title bar or tab.
  2. <meta>: Defines metadata about the document, such as character encoding, viewport settings for responsive design, authorship information, or keywords for search engines.
  3. <link>: Links external stylesheets, icon files (favicon), or other external resources.
  4. <style>: Contains embedded CSS styles specific to the document.
  5. <script>: Embeds or references JavaScript code or external JavaScript files.
  6. <base>: Specifies the base URL for relative URLs within the document.

Here's an example of how the <head> element is typically structured:

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Page Title</title>
  <link rel="stylesheet" href="styles.css">
  <script src="script.js"></script>
</head>
<body>
  <!-- Content of the web page -->
</body>
</html>

 

The <head> element plays a crucial role in providing information and instructions to the browser, search engines, and other tools that process the webpage. Some key usages of the <head> element and its contents include:

  1. Setting the title: The <title> element defines the title of the webpage, which appears in the browser's title bar or tab. It helps users identify the page and is used by search engines and social media platforms when displaying search results or shared links.

  2. Specifying metadata: The <meta> element allows you to define metadata about the document, such as character encoding, viewport settings for responsive design, authorship information, keywords for search engines, or other custom metadata. These metadata provide additional information and instructions to the browser and search engines.

  3. Linking external resources: The <link> element is used to link external resources, such as stylesheets, icon files (favicon), or other external files required by the document. This allows you to separate styling and functionality into separate files and improve maintainability.

  4. Embedding or referencing scripts: The <script> element is used to embed or reference JavaScript code or external JavaScript files. This enables you to enhance the interactivity and functionality of the webpage.

  5. Defining styles: The <style> element allows you to embed CSS styles specific to the document. This is useful for defining custom styles or overriding default styles for the webpage.

  6. Setting the base URL: The <base> element specifies the base URL for relative URLs within the document. It provides a convenient way to set a common base URL for all relative URLs within the page.

Overall, the <head> element and its contents provide important information and instructions for the browser, search engines, and other tools to interpret and display the HTML document properly.

The <meta> element is used to provide metadata about an HTML document. Metadata describes various aspects of the document, such as its character encoding, authorship, viewport settings, keywords for search engines, and more. The <meta> element is placed within the <head> section of an HTML document.

The <meta> element does not have a closing tag and is self-closing. It uses attributes to specify different types of metadata. Here are some commonly used attributes:

  1. charset: Specifies the character encoding for the HTML document. For example, <meta charset="UTF-8"> sets the character encoding to UTF-8, which is widely used for handling international characters.

  2. name and content: Used together to define various types of metadata. The name attribute specifies the type of metadata, and the content attribute provides the value for that metadata. For example:

    • <meta name="description" content="A brief description of the page"> specifies a description of the webpage.
    • <meta name="keywords" content="HTML, metadata, SEO"> specifies keywords relevant to the webpage.
    • <meta name="author" content="John Doe"> specifies the author of the webpage.
  3. viewport: Used for responsive web design to control the viewport's behavior on mobile devices. For example, <meta name="viewport" content="width=device-width, initial-scale=1.0"> ensures that the webpage is displayed correctly on various devices with different screen sizes.

  4. Other attributes: There are additional attributes that can be used in specific cases, such as http-equiv, which specifies an HTTP response header value, or property, which is used for social media sharing and Open Graph metadata.

The number of possible types of metadata that can be specified with the <meta> element is not limited. The type of metadata depends on the name attribute value, and you can create custom metadata to suit your specific needs.

Commonly used <meta> elements include those for character encoding (charset), description (description), keywords (keywords), author (author), viewport (viewport), and others related to social media sharing or SEO (Search Engine Optimization).

It's important to note that not all <meta> elements have an impact on the visual appearance of the webpage, but they provide essential information to browsers, search engines, and other tools that process the HTML document.

Latest Tutorial

Newly published tutorials

Laravel 10 - Tutorial to create CRUD Application

Learn to create crud application using laravel 10. Step by step guidance will help to understand the concept of crud.

Laravel - How to upload file to AWS S3 Bucket

Explore how we can upload file using the laravel on Amazon S3 bucket.

Laravel 10 - Send mail using AWS SES

Learn to send Email using Laravel 10 with AWS SES service.