Lesson 2 +10 XP

Your First Web Page

Let's build a tiny web page and look at the parts of the skeleton.

The skeleton of every page

Code

html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>My First Page</title>
  </head>
  <body>
    <h1>Hello, World!</h1>
    <p>This is my first web page.</p>
  </body>
</html>

The parts

  • &lt;!DOCTYPE html&gt;: a special instruction that tells the browser &quot;this is a modern HTML page.&quot; It's not a tag, just a declaration. Always put it on the very first line!
  • &lt;html&gt;: the root element. Everything lives inside it.
  • &lt;head&gt;: the brain-in-the-background. It holds secret info the page needs but doesn't show.
  • &lt;title&gt;: the text you see on the browser tab. It lives in the head.
  • &lt;meta&gt;: gives the browser extra info, like which characters to use (charset).
  • &lt;body&gt;: everything visible on the page lives here.

lang attribute

lang=&quot;en&quot; tells the browser &quot;this page is written in English.&quot; This helps screen readers pronounce words correctly and search engines understand your page.

Comments

You can leave notes for yourself with comments. They don't show up on the page:

Code

html
<! - This is a comment. Nobody sees me! - >

Comments start with `&lt;!

  • and end with - &gt;`.

TL;DR

  • &lt;!DOCTYPE html&gt; must be the first line.
  • &lt;html&gt; wraps everything.
  • &lt;head&gt; holds secret info; &lt;body&gt; holds visible stuff.
  • &lt;title&gt; is the browser tab text.