Build Your Website from Scratch (2): Set Up Your Tools and Write Your First HTML Page

Set up a free editor, create the project folder, write a valid HTML document, test it on mobile, fix the tiny-text problem with one tag, and validate the code with the official W3C tool.

Build Your Website from Scratch (2): Set Up Your Tools and Write Your First HTML Page
Set up a free editor, create the project folder, write a valid HTML document, test it on mobile, fix the tiny-text problem with one tag, and validate the code with the official W3C tool.

Build Your Website from Scratch (2): Set Up Your Tools and Write Your First HTML Page

Share:
⏱ 6 min read🔄 Updated: 2026-12-01✍ NOOR 4 TECH team

In this part you set up your workspace and write your first complete HTML page by hand.
Key fact: a plain text file named index.html is enough to show your page in a browser, and without the viewport tag the text looks tiny on mobile.
Follow the steps in order, then open the page in a mobile view and confirm the text is readable.

In part 1 we followed the journey of a page request from URL to rendered pixels. Today we pick up the tools: a free working environment, a complete first HTML page, and a browser check on desktop and mobile. By the end you have a working page on your own machine, ready to grow into the full site.

What we will do in this part

  1. Set up a free code editor, plus an option that needs no installation.
  2. Create the project folder and the first index.html file.
  3. Write a valid HTML document from scratch.
  4. Open it in the browser and check it on desktop and mobile.
  5. Validate the code with the official validator before publishing.

1. Choosing an editor: VS Code in five minutes

Any text editor works, but VS Code is free, the most widely used editor for web work, and runs on Windows, macOS, and Linux.

  1. Open code.visualstudio.com and download the build for your system.
  2. Run the installer and keep the defaults (Next through to the end).
  3. Open the editor, press Ctrl+Shift+X for extensions, and install two:
    • Arabic Language Pack if you prefer an Arabic interface.
    • Live Server: serves your page locally and refreshes it on every save.

No-install option: if you cannot install software, use a browser editor such as CodePen or JSFiddle. The code is identical; the difference is that you cannot run PHP there, so we will need VS Code by part 5.

2. Create the project folder and the first file

  1. Create a folder named my-site on your desktop.
  2. In VS Code choose File → Open Folder and select it.
  3. From the sidebar, click the new-file icon and name it index.html, all lowercase.

The name index.html is not optional: it is the file a server serves automatically when a visitor opens the domain with no path.

3. A complete first HTML document

Copy this into the file and save with Ctrl+S:

<!doctype html>
<html lang="en" dir="ltr">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>My first page</title>
</head>
<body>
  <h1>Welcome to my first website</h1>
  <p>This is the first page I wrote myself, and I will build a full site on it.</p>

  <h2>What will I learn in this series?</h2>
  <ul>
    <li>Writing valid HTML pages.</li>
    <li>Styling them with a responsive layout.</li>
    <li>Publishing them on the internet.</li>
  </ul>

  <p>Learn more: <a href="https://developer.mozilla.org/">MDN documentation</a></p>
</body>
</html>

Every line has a job:

  • <!doctype html>: tells the browser this is modern HTML; without it the browser falls back to legacy quirks mode.
  • <html lang="en" dir="ltr">: page language and direction. For Arabic content use lang="ar" dir="rtl".
  • <meta charset="utf-8">: character encoding. Omit it and non-Latin text turns into symbols.
  • <title>: the tab title and the headline in search results.
  • <h1>: the main heading, exactly one per page.
  • <p>: a paragraph of text.
  • <ul> and <li>: a bulleted list and its items.
  • <a href="...">: a link, with its destination in href.

4. See the result

Open the project folder and double-click index.html, or right-click it in VS Code and choose Open with Live Server.

The first HTML page open in a browser: a heading, a paragraph, a bulleted list, and a link
Figure 1: The first HTML page open in a browser: a heading, a paragraph, a bulleted list, and a link

The page has no styling, which is expected: we have not written any CSS yet. What matters is that the elements appear in the right order and the direction is correct.

5. Add an image and check the tag

Save any small image in the same folder as photo.jpg and add this line before the list:

<img src="photo.jpg" alt="A test image inside my first page" width="400">
  • src: the image path. When the file sits in the same folder, the name alone is enough.
  • alt: the text shown if the image fails, read by screen readers and used by Google. Not optional.
  • width: the display width in pixels, which also reduces layout shift while loading.

6. The real test: mobile

Press F12, toggle device mode with Ctrl+Shift+M, and pick a 390-pixel viewport. The text shrinks to a tiny size:

The page at a 390 pixel mobile viewport before adding the viewport meta tag: text is tiny
Figure 2: The page at a 390 pixel mobile viewport before adding the viewport meta tag: text is tiny

The cause: the browser assumes a desktop-width page (around 980 pixels) and scales the whole thing down to fit. The fix is one line inside <head>:

<meta name="viewport" content="width=device-width, initial-scale=1">

Save, reload, and see the difference:

The same page after adding the viewport meta tag: text is readable on mobile
Figure 3: The same page after adding the viewport meta tag: text is readable on mobile

Expected result: the text is readable and the link is easy to tap. This tag is the first requirement of any responsive design, and it belongs in every page you build from now on.

Tip: name files in lowercase English letters with no spaces, like index.html, to avoid link problems later.

7. Validate the code before moving on

  1. Open the official W3C validator, choose Validate by File Upload, and upload your file.
  2. You should see No errors or warnings to show. If errors appear, read the line number and fix it.
  3. In the browser press Ctrl+U to view the source and confirm it matches what you wrote.
Warning: on Windows, File Explorer can hide file extensions, so your file may end up named index.html.txt without you noticing. Turn on file extensions and check the name.

8. Common first-page mistakes

  1. Wrong file extension, such as index.html.txt, which opens as plain text. The extension must be .html only.
  2. Forgetting charset="utf-8", so non-Latin text shows as symbols.
  3. Forgetting dir="rtl" for Arabic pages, so text starts on the wrong side and punctuation lands oddly.
  4. More than one <h1> on a page, which confuses search engines.
  5. Unclosed tags such as <p> without </p>, which causes strange nesting later.

9. Summary and what comes next

You now have a project on your machine, a valid first page, a way to test it on mobile, and an official validator to check it.

In part 3 we build a proper page structure with semantic HTML (header, nav, main, section, footer), and see why the right element beats a <div> for everything, for both SEO and screen readers.

If you would rather have a finished site than build one yourself, you can request a website design service from the Noor4Tech team.

FAQ

Is VS Code really free?

Yes, fully free for personal and commercial use, with no subscription.

Do I need internet to open my page?

No. The page is a file on your machine and opens offline. Internet is only needed if the page loads images or fonts from an external site.

Why does the page have no colours or styling?

Because styling is CSS, which we have not written yet. HTML defines content and meaning; CSS defines appearance.

What is the difference between Live Server and opening the file directly?

For static pages the visible result is the same. Live Server reloads the browser on every save, and it matters later when we run PHP.

🔗 Official sources

Series: part 2 of Build Your Website from Scratch — previous part: how a website works · series index · next: semantic HTML and page structure.

⭐ Featured Recommendation

📈 Double Your Site Traffic & Revenue with Featured Backlinks & SEO

Get a pinned Featured Backlink in our directory or a complete SEO audit by NOOR 4 TECH experts to dominate rankings.

Explore Featured Package ⭐
💼 NOOR 4 TECH Professional Services

Looking for a Technical Partner for Your Next Project?

We deliver enterprise web development, mobile apps, technical SEO, and AI automation.

Author

Noor4Tech Team

We are a specialized team in providing the best technical and programming content to help you achieve your digital goals.

Comments (0)

No comments yet. Be the first to comment!

Add Your Comment

Your email will not be published. Comments require review before publishing.