HTML First Page
A first HTML page is a complete document with a head section and a body section. The body holds the content that appears on screen.
The first line
This declaration tells the browser the document is HTML. It appears before every other line.
<!DOCTYPE html>The head and title
The title sits inside the head. Its text appears on the browser tab, not in the body.
<head>
<title>My Page</title>
</head>The body content
Headings and paragraphs sit inside the body. Their text appears on the page.
<body>
<h1>Hello</h1>
<p>Welcome to my page.</p>
</body>Example
<!DOCTYPE html>
<html>
<head>
<title>About Me</title>
</head>
<body>
<h1>About Me</h1>
<p>I am learning HTML.</p>
<p>This is my first page.</p>
</body>
</html>Key points
- DOCTYPE: a declaration that names the document type
- Use <!DOCTYPE html> as the first line of every page
- html element: the element that holds the whole document
- head element: the part that holds information about the page
- title element: the element that sets the text on the browser tab
- body element: the part that holds the visible content
In this example, the doctype line comes first. The html element wraps the whole document. The head holds the title About Me. The body holds one heading and two paragraphs. The browser shows the heading and paragraphs on the page. The title appears on the browser tab.
Note
Save the file with an .html ending so a browser opens it as a page.
Try it Yourself
Edit the code, then press Run.
Runs in your browser โ the preview under the editor is the real result. Nothing is sent to a server. The code runner panel (right) does the same with more room.
Exercise
Which part of the page holds the visible content?