The head and body tags have different roles. The head section contains metadata about the document that users do not see. This includes the title tag for the browser tab, meta tags for character encoding and search engine descriptions, links to CSS stylesheets, and script tags for JavaScript. This content is hidden but important for how the page functions. The body section contains all visible content. This includes headings, paragraphs, images, videos, links, buttons, forms, and tables. Everything users see on screen is in the body. The browser renders and displays all body content. The head always comes before the body in the document. Both sections are required. You can only have one head and one body per document, but the body can have unlimited nested elements inside it. The head loads first, so stylesheets and scripts are ready before visible content appears.
Example code
<!DOCTYPE html>
<html>
<head>
<!-- METADATA - Not visible -->
<title>Head vs Body Example</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="styles.css">
<script src="script.js"></script>
</head>
<body>
<!-- VISIBLE CONTENT -->
<h1>This heading is visible</h1>
<p>This paragraph is visible</p>
<button>This button is visible</button>
<img src="photo.jpg" alt="This image is visible">
</body>
</html>