Sobes.tech
Intern

What is the purpose of the <head> tag in an HTML document?

sobes.tech AI

Answer from AI

<head> contains metadata about the HTML document that is not displayed directly to the user.

Key elements inside <head>:

  • <title>: Defines the page title, displayed in the browser tab.
  • <meta>: Provides metadata such as character encoding (charset), description (description), keywords (keywords), author (author), and viewport (viewport).
  • <link>: Links to external resources like CSS stylesheets (rel="stylesheet").
  • <script>: Embeds or links to JavaScript scripts. Note: Scripts are often moved to the end of <body> to improve load speed.
  • <style>: Embeds CSS styles directly into the document.
  • <base>: Specifies the base URL for all relative links on the page.