HTML Document Structure
HTML Living Standard
An HTML document has a head for page information and a body for the content visitors see. Start with one complete file.
On this page
A complete HTML document
Save this example as index.html. The title belongs in the head and the paragraph belongs in the body.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Learning Center</title>
</head>
<body>
<p>Welcome to the Learning Center!</p>
</body>
</html>
What to expect The preview displays the welcome message. If you open index.html directly, the browser tab says Learning Center. Change the paragraph and run again.
The root element <html>
<html> contains the head and body. Set lang="en" for a page in English or lang="my" for a page in Burmese. Screen readers use the language to pronounce the text.
Page information <head>
<head> holds information about the page, such as its character encoding. Save the file as UTF-8 and put <meta charset="utf-8"> near the start of the head.
The browser tab title <title>
Use <title> in the head for the name shown in the browser tab and bookmarks. Use <h1> in the body for the main heading readers see on the page.
Visible content <body>
Put headings, paragraphs, links, and other content inside <body>, after </head>.
Set the layout width on phones
The viewport is the part of the browser in which the page is displayed. Mobile browsers may lay out pages as if they had a wider screen. width=device-width asks the browser to use the device width for the page layout. initial-scale=1 sets the initial zoom.
How to try it Add this line inside the existing <head>, after the charset line.
<meta name="viewport" content="width=device-width, initial-scale=1">
What to expect The greeting stays the same. On a phone the browser can use the phone width to lay out the page. Try it again when you build a responsive layout.