What you need
HTML does not need a language installer, compiler or package manager. A plain-text editor and a modern web browser are enough. A code editor such as VS Code can make writing easier, but it is optional. Use a plain-text file rather than a word processor document: formatting added by a word processor is not HTML source.
You can also try an example in Codectionary’s Playground before making a local file. For a page you can keep and edit on your computer, create a project folder first so related files have a clear home.
Create and save index.html
Create a folder named my-first-page. In your editor, make a new plain-text file and save it in that folder as index.html. The .html extension tells your system and editor that this file contains HTML; index.html is a common name for a site’s starting page. If your editor offers a file-type selector, choose HTML or All Files so it does not silently append .txt.
Copy the complete example below. The first line requests standards mode. The html element contains the document and lang="en" declares its English language. The head contains metadata: character encoding, a mobile viewport instruction and the title shown in the browser tab. The body contains the visible heading, paragraphs and link. The main element identifies the central content.
Open it in a browser
Find index.html in the folder and open it with a browser, or drag the file into a browser window. The browser reads the file directly from your computer, so you do not need a web server for this simple page. You should see the heading, text and clickable Example Domain link; “My first webpage” appears in the tab.
Change the heading text, save the file and refresh the browser. Saving writes the edited source to disk; refreshing makes the browser read it again. If nothing changes, confirm you edited the same index.html that the browser opened and that the editor saved the file.
Build on this foundation
The example demonstrates structure rather than visual design. Continue with headings, links and images, then add CSS for appearance and JavaScript when you need behaviour. Use semantic elements because their meaning helps readers, browsers and assistive technology interpret a page.
Syntax
<!doctype html>
<html lang="en">
<head><title>My page</title></head>
<body><h1>Hello!</h1></body>
</html>Examples
A complete first page
Save this as index.html and open it in a browser.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My first webpage</title>
</head>
<body>
<main>
<h1>Welcome to my webpage</h1>
<p>I'm learning how to give a page structure with HTML.</p>
<p>Visit <a href="https://example.com/">Example Domain</a>.</p>
</main>
</body>
</html>- The doctype selects standards mode, while html, head and body form the document skeleton.
- The title belongs in head and names the browser tab. The h1 and paragraphs belong in body and appear on the page.
- The anchor element creates a link. Its href attribute gives the destination; the link text tells the reader where it goes.
- After saving, change the heading and refresh to verify that the browser is reading your edited file.
Best practices
- Save as .html, not .html.txt.
- Set a useful title and document language.
- Use meaningful elements and descriptive link text.
Browser compatibility
Support applies to the named feature, not every attribute or behaviour in this article. Versions refer to browsers, not operating systems.
These records cover the elements and link attribute in the first-page example, not the whole process of editing or opening local files.
<html>
Desktop
- Chrome
- Supported
From 1 - Firefox
- Supported
From 1 - Safari
- Supported
From 1 - Edge
- Supported
From 12 - Opera
- Supported
By 12.1 (possibly earlier)
Mobile
- Safari on iOS
- Supported
From 1 - Chrome for Android
- Supported
From 18 - Firefox for Android
- Supported
From 4 - Samsung Internet
- Supported
From 1.0
MDN BCD record for this feature · MDN reference
Support history and limitations
Chrome
- From 1
Firefox
- From 1
Safari
- From 1
Edge
- From 12
Opera
- By 12.1 (possibly earlier)
Safari on iOS
- From 1
Chrome for Android
- From 18
Firefox for Android
- From 4
Samsung Internet
- From 1.0
<head>
Desktop
- Chrome
- Supported
From 1 - Firefox
- Supported
From 1 - Safari
- Supported
From 1 - Edge
- Supported
From 12 - Opera
- Supported
From 15
Mobile
- Safari on iOS
- Supported
From 1 - Chrome for Android
- Supported
From 18 - Firefox for Android
- Supported
From 4 - Samsung Internet
- Supported
From 1.0
MDN BCD record for this feature · MDN reference
Support history and limitations
Chrome
- From 1
Firefox
- From 1
Safari
- From 1
Edge
- From 12
Opera
- From 15
Safari on iOS
- From 1
Chrome for Android
- From 18
Firefox for Android
- From 4
Samsung Internet
- From 1.0
<body>
Desktop
- Chrome
- Supported
From 1 - Firefox
- Supported
From 1 - Safari
- Supported
From 1 - Edge
- Supported
From 12 - Opera
- Supported
From 15
Mobile
- Safari on iOS
- Supported
From 1 - Chrome for Android
- Supported
From 18 - Firefox for Android
- Supported
From 4 - Samsung Internet
- Supported
From 1.0
MDN BCD record for this feature · MDN reference
Support history and limitations
Chrome
- From 1
Firefox
- From 1
Safari
- From 1
Edge
- From 12
Opera
- From 15
Safari on iOS
- From 1
Chrome for Android
- From 18
Firefox for Android
- From 4
Samsung Internet
- From 1.0
<main>
Desktop
- Chrome
- Supported
From 26 - Firefox
- Supported
From 21 - Safari
- Supported
From 7 - Edge
- Supported
From 12 - Opera
- Supported
From 16
Mobile
- Safari on iOS
- Supported
From 7 - Chrome for Android
- Supported
From 26 - Firefox for Android
- Supported
From 21 - Samsung Internet
- Supported
From 1.5
MDN BCD record for this feature · MDN reference
Support history and limitations
Chrome
- From 26
Firefox
- From 21
Safari
- From 7
Edge
- From 12
Opera
- From 16
Safari on iOS
- From 7
Chrome for Android
- From 26
Firefox for Android
- From 21
Samsung Internet
- From 1.5
<h1>
Desktop
- Chrome
- Supported
From 1 - Firefox
- Supported
From 1 - Safari
- Supported
From 1 - Edge
- Supported
From 12 - Opera
- Supported
From 15
Mobile
- Safari on iOS
- Supported
From 1 - Chrome for Android
- Supported
From 18 - Firefox for Android
- Supported
From 4 - Samsung Internet
- Supported
From 1.0
MDN BCD record for this feature · MDN reference
Support history and limitations
Chrome
- From 1
Firefox
- From 1
Safari
- From 1
Edge
- From 12
Opera
- From 15
Safari on iOS
- From 1
Chrome for Android
- From 18
Firefox for Android
- From 4
Samsung Internet
- From 1.0
<p>
Desktop
- Chrome
- Supported
From 1 - Firefox
- Supported
From 1 - Safari
- Supported
From 1 - Edge
- Supported
From 12 - Opera
- Supported
From 15
Mobile
- Safari on iOS
- Supported
From 1 - Chrome for Android
- Supported
From 18 - Firefox for Android
- Supported
From 4 - Samsung Internet
- Supported
From 1.0
MDN BCD record for this feature · MDN reference
Support history and limitations
Chrome
- From 1
Firefox
- From 1
Safari
- From 1
Edge
- From 12
Opera
- From 15
Safari on iOS
- From 1
Chrome for Android
- From 18
Firefox for Android
- From 4
Samsung Internet
- From 1.0
<a> href
Desktop
- Chrome
- Supported
From 1 - Firefox
- Supported
From 1 - Safari
- Supported
From 1 - Edge
- Supported
From 12 - Opera
- Supported
From 15
Mobile
- Safari on iOS
- Supported
From 1 - Chrome for Android
- Supported
From 18 - Firefox for Android
- Supported
From 4 - Samsung Internet
- Supported
From 1.0
MDN BCD record for this feature
Support history and limitations
Chrome
- From 1
Firefox
- From 1
Safari
- From 1
Edge
- From 12
Opera
- From 15
Safari on iOS
- From 1
Chrome for Android
- From 18
Firefox for Android
- From 4
Samsung Internet
- From 1.0
MDN BCD 8.1.5 · Dataset built 2026-10-08 · Mapping reviewed 2026-10-21. These dates are not individual browser-test or claim-verification dates. Unknown means the data does not establish support.