2. The Page Skeleton

Every complete HTML page follows the same skeleton. The doctype tells the browser which version of HTML to use. The html element wraps everything. The head holds information about the page that is not shown (the title and settings). The body holds everything the visitor sees. Most HTML is written as tags in pairs: an opening tag like <p> and a closing tag like </p>, with content between them.

Key points

  • <!DOCTYPE html> must be the first line.
  • <head> contains <title> (the browser tab text), <meta> settings and CSS links.
  • <body> contains the visible page.
  • Tags can be nested inside each other, but must be closed in the right order.
  • In MVC, the skeleton lives once in _Layout.cshtml and each view fills the body.

Example: A complete page

HTML and CSS Open in editor
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>My First Page</title>
</head>
<body>
  <h1>Welcome</h1>
  <p>This is the visible part of the page.</p>
</body>
</html>
Show explanation

The title does not appear inside the preview (it shows in a real browser tab). Everything inside body is displayed.

Try it yourself

Edit the code below and press Run. The result appears in the preview underneath.

Editor
Reset Preview runs in a safe sandbox. Scripts are disabled.
PREVIEW