TOP CATEGORIES

×

What is the difference between head and body in HTML?

B

Bright Madhu

<head> & <body> Section in HTML

The <head> element is used for metadata, document information, and links to external resources, while the <body> element is used for the visible content of the web page.

<head> Section with Elements

<head> element is used to contain meta-information and resources that provide essential details about the document but are not directly visible on the web page such as:

  • <title>: It specifies the title of the web page, which appears in the browser's title bar or tab.
  • <meta>: It provides metadata about the document, such as the character encoding (charset), viewport settings for responsive design, author information, and more.
  • <link>: It links to external resources like stylesheets (CSS) or icons.
  • <script>: It usually includes references to external scripts or inline JavaScript code.
  • <style>: It contains CSS styles or references to external CSS files.

Syntax Example of <head> Section

<head>

  <meta charset="UTF-8">

  <title>First Web Page</title>

  <link rel="stylesheet" href="styles.css">

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

</head>

<body> Section with Elements

The <body> element contains the visible content of the web page that users see and interact with the browser such as text, images, videos, links, forms, and other HTML elements that make up the actual webpage.

Syntax Example of <body> Section

<body>

  <h1>Hello, World!</h1>

  <p>Welcome to the web page.</p>

  <img src="image.jpg" alt="Image description">

  <a href="https://www.ABC-XYZ.com">visit ABC-XYZ website</a>

</body>

1 votes

Your Answer

Email: advertise@gdatamart.com

Donate: To Support US

© 2024 GDATAMART.COM (All Rights Reserved)