Skip to main content

How to Create Your First HTML File

· 4 min read
Charly Abraham
Co-Founder, Phoenix Code

You can make a web page with one file on your computer. You’ll create index.html, write a notice for a Saturday book swap, and open it in Chrome. You can try it before you have a website or a hosting account.

These steps work in both Phoenix Pro and Community (free). Follow along with desktop Chrome and the Phoenix Code desktop app.

Create a file named index.html​

  1. Open Documents in File Explorer on Windows, Finder on Mac, or Files on Linux. Create an empty folder called first-page.
  2. In Phoenix Code, click the folder with a plus at the top left. Choose Open Folder…, select first-page, and open it. Look for first-page in the Files sidebar.
  3. Choose File → New File. You can also right-click the empty space below first-page and choose New File. A filename box appears there with a suggested name selected. Type index.html and press Enter.
In the Phoenix Code Files sidebar, the filename box below first-page contains index.html.

The .html ending tells the browser to read the file as a web page. The name index.html is commonly used for a website’s home page.

Write and save your page​

Click inside the index.html editor. Select all its starter code with Ctrl+A on Windows or Linux, or Command+A on Mac. Replace it with this example.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1">
<title>Library noticeboard</title>
</head>
<body>
<h1>Saturday book swap</h1>
<p>Bring a book to trade at the library.</p>
</body>
</html>

Choose File → Save File, or press Ctrl+S on Windows or Linux and Command+S on Mac. The file you just saved is inside first-page.

Open the saved file in Chrome​

Open your first-page folder and a Chrome window side by side. Drag index.html from the folder into an empty Chrome tab. To use the keyboard instead, switch to Chrome, press Ctrl+O on Windows or Linux or Command+O on Mac, select index.html, and choose Open.

Chrome displays Library noticeboard on the tab and a local path ending in first-page/index.html. The page shows Saturday book swap above Bring a book to trade at the library.

Library noticeboard comes from <title> and appears on the tab. Saturday book swap comes from <h1> and appears on the page. To try an edit, change Saturday to Sunday inside <h1> in Phoenix Code. Save, then click Chrome’s Reload (the circular arrow). The heading changes to Sunday book swap and the tab still says Library noticeboard.

Why does Chrome show the HTML tags?​

Check the full filename in the Phoenix Code Files sidebar. If it reads index.html.txt, the final .txt makes Chrome display the file as plain text.

  1. Right-click index.html.txt and choose Rename. Phoenix Code may select only index.
  2. With the filename box active, press Ctrl+A or Command+A to select the whole name. Type index.html and press Enter.
  3. Open the renamed file in Chrome again. You should see the book swap heading.
The Rename field shows index selected while .html.txt is still outside the selection.

If the file already ends in .html, check Chrome’s address bar. An address starting with view-source: opens the source code in its own tab. Switch back to the page tab to see the heading. More ways to open and check a local HTML file in Chrome