What is the <head> element in HTML?

The <head> element in HTML is a container for the metadata of the HTML document. contains information about the title of the page, the author’s name, links to CSS or custom favicons, reference to other sources, any scripts to make webpage interactive, or any key information describing the document. This data is not displayed on the webpage. The following HTML elements can be used inside the <head> element:

  • <title>
  • <style>
  • <base>
  • <link>
  • <meta>
  • <script>
  • <noscript>

The <title> element must be present underneath the <head> element in order for the webpage to be complete.

Example

Explanation

The HTML document above displays a simple webpage containing a heading and a body. In lines 3-10, you can see the <head> element and the elements inside it describing the metadata of the document.

  • <title> describes the title of the webpage.
  • <meta> specifies the character set encoding for the HTML document.
  • <style> instructs the styling throughout the webpage.
  • <head> acts as a container that wraps the metadata to better structure the HTML document.

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved