HTML Online for Android — the same editor with live preview, visual mode and HTML tools, offline Get the app
  1. Home
  2. Learn
  3. Make a website with HTML

Guide · 7 min read

How to make a website with HTML and CSS

Build a small but real 3-page website from an empty folder: the HTML pages, a navigation menu, an image, a stylesheet, a layout that works on phones, and how to put it online. Every file is shown in full.

Quick answerTo make a website with HTML and CSS, create a folder with an index.html file for the home page, write the page structure in HTML, add more pages and link them with <a href>, then style everything from one style.css file linked in each page's <head>. Test it in a browser, then upload the folder to a free host such as GitHub Pages.

You only need a text editor and a browser. The example is a small bakery website with three pages. Follow along, or swap in your own words and colours as you go.

The finished bakery website on a laptop and on a phone: a brown header with a menu, a large heading, an orange button, a bread illustration and three product cards
The finished site from this guide, in Chrome at laptop width and at phone width.

Step 1: Plan the pages and create a folder

Decide which pages you need. A small business site usually starts with three: Home, About and Contact. Create a folder for the site and this structure inside it:

crumb-and-co/
├── index.html      ← the home page (always called index.html)
├── about.html
├── contact.html
├── style.css       ← one stylesheet for every page
├── script.js
└── images/
    └── bread.svg

Use lowercase file names with no spaces. Web servers open index.html automatically when someone visits the folder, which is why the home page has that name.

Step 2: Write the home page in HTML

Open a text editor (VS Code, Notepad, TextEdit in plain-text mode, or the online HTML editor) and save this as index.html. It starts from the standard HTML5 boilerplate, then adds a header with a menu, the main content and a footer:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Crumb &amp; Co. Bakery</title>
  <meta name="description" content="Fresh bread and pastries baked every morning.">
  <link rel="stylesheet" href="style.css">
  <script src="script.js" defer></script>
</head>
<body>
  <header>
    <a class="logo" href="index.html">Crumb &amp; Co.</a>
    <nav>
      <a href="index.html" aria-current="page">Home</a>
      <a href="about.html">About</a>
      <a href="contact.html">Contact</a>
    </nav>
  </header>
  <main>
    <section class="hero">
      <div>
        <h1>Fresh bread, baked every morning</h1>
        <p>Sourdough, croissants and cinnamon buns from our small neighbourhood bakery.</p>
        <a class="button" href="contact.html">Order for pickup</a>
      </div>
      <img src="images/bread.svg" alt="A loaf of sourdough bread" width="320" height="220">
    </section>
    <section class="cards">
      <article class="card"><h2>Sourdough</h2><p>Slow-fermented for 24 hours for a crisp crust.</p></article>
      <article class="card"><h2>Croissants</h2><p>Buttery layers, baked fresh at 7 am.</p></article>
      <article class="card"><h2>Cinnamon buns</h2><p>Soft, sticky and usually gone by noon.</p></article>
    </section>
  </main>
  <footer>&copy; <span id="year">2026</span> Crumb &amp; Co. Bakery</footer>
</body>
</html>

Open the file in your browser (double-click it). Without CSS it looks plain, but every part is already there: headings, text, a button-style link, an image and three cards. Semantic tags such as <header>, <nav>, <main>, <section> and <footer> tell browsers, screen readers and search engines what each part is.

Step 3: Add more pages and link them with a menu

Copy index.html twice, rename the copies about.html and contact.html, and replace what's inside <main>. Give each page its own <title> and description, and move aria-current="page" to that page's menu link so the current page is highlighted. This is the About page:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>About us | Crumb &amp; Co. Bakery</title>
  <meta name="description" content="How a two-person bakery started.">
  <link rel="stylesheet" href="style.css">
  <script src="script.js" defer></script>
</head>
<body>
  <header>
    <a class="logo" href="index.html">Crumb &amp; Co.</a>
    <nav>
      <a href="index.html">Home</a>
      <a href="about.html" aria-current="page">About</a>
      <a href="contact.html">Contact</a>
    </nav>
  </header>
  <main>
    <h1>About us</h1>
    <p>Crumb &amp; Co. started in 2019 with one oven and two bakers who wanted good bread on every street.</p>
    <p>Everything is made by hand from local flour, every morning.</p>
  </main>
  <footer>&copy; <span id="year">2026</span> Crumb &amp; Co. Bakery</footer>
</body>
</html>

The menu is a set of ordinary links between files in the same folder: <a href="about.html">. The guide to HTML links explains paths for pages in other folders, email and phone links, and more. The Contact page uses those email and phone links:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Contact | Crumb &amp; Co. Bakery</title>
  <meta name="description" content="Opening hours, phone and email.">
  <link rel="stylesheet" href="style.css">
  <script src="script.js" defer></script>
</head>
<body>
  <header>
    <a class="logo" href="index.html">Crumb &amp; Co.</a>
    <nav>
      <a href="index.html">Home</a>
      <a href="about.html">About</a>
      <a href="contact.html" aria-current="page">Contact</a>
    </nav>
  </header>
  <main>
    <h1>Contact</h1>
    <p>Email <a href="mailto:hello@example.com">hello@example.com</a> or call <a href="tel:+15551234567">+1 555 123 4567</a>.</p>
    <table>
      <tr><th>Monday to Friday</th><td>7:00 to 18:00</td></tr>
      <tr><th>Saturday</th><td>8:00 to 14:00</td></tr>
    </table>
  </main>
  <footer>&copy; <span id="year">2026</span> Crumb &amp; Co. Bakery</footer>
</body>
</html>

Want a contact form instead of (or as well as) the email link? Build one with the HTML form builder and paste it into <main>.

Step 4: Add images

Put image files in the images folder and add them with <img>:

<img src="images/bread.svg" alt="A loaf of sourdough bread" width="320" height="220">
  • src is the path to the file, starting from the page's folder.
  • alt describes the picture for people who can't see it and for search engines. Leave it empty (alt="") only for decorative images.
  • width and height let the browser reserve space before the image loads, so the page doesn't jump.

Use JPEG or WebP for photos, PNG or SVG for logos and drawings, and keep photos under about 200 KB so pages load fast on phones.

Step 5: Style the site with CSS

Save this as style.css. Every page already loads it with <link rel="stylesheet" href="style.css"> in its head, so one file styles the whole site (more on this in how to link CSS to HTML):

* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; line-height: 1.6; color: #2b2622; background: #fffaf3; }

header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
         gap: 12px; padding: 16px 24px; background: #7a4a24; }
.logo { color: #fff; font-weight: 700; font-size: 1.3rem; text-decoration: none; }
nav a { color: #ffe9d2; text-decoration: none; margin-left: 18px; }
nav a:hover, nav a[aria-current="page"] { color: #fff; text-decoration: underline; }

main { max-width: 960px; margin: 0 auto; padding: 32px 24px; }
h1 { font-size: 2.4rem; line-height: 1.2; margin: 0 0 12px; color: #7a4a24; }

.hero { display: flex; flex-wrap: wrap; align-items: center; gap: 32px; }
.hero div { flex: 1 1 300px; }
.hero img { flex: 1 1 260px; max-width: 100%; height: auto; }
.button { display: inline-block; padding: 10px 20px; background: #e07a2f; color: #fff;
          border-radius: 8px; text-decoration: none; font-weight: 600; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-top: 32px; }
.card { background: #fff; border: 1px solid #f0e2d0; border-radius: 12px; padding: 18px; }

footer { text-align: center; padding: 24px; color: #8a7a6a; font-size: .9rem; }

@media (max-width: 600px) {
  h1 { font-size: 1.8rem; }
  nav a { margin: 0 14px 0 0; }
}
The bakery home page before and after adding the stylesheet: first plain black text in a default font, then a brown header, orange heading and button, and product cards
The home page from step 2 without the stylesheet (left) and with style.css linked (right).

The main ideas in this stylesheet:

  • Flexbox (display: flex) lines up the logo and menu in the header, and the text and image in the hero.
  • CSS grid (repeat(auto-fit, minmax(220px, 1fr))) makes as many card columns as fit: three on a laptop, one on a phone, with no extra code.
  • max-width on main keeps lines of text at a comfortable reading length on wide screens.

Step 6: Make it work on phones

Two things make a site responsive:

  1. The viewport tag in every page's head: <meta name="viewport" content="width=device-width, initial-scale=1">. Without it, phones show a tiny zoomed-out desktop page.
  2. Layouts that wrap (flex-wrap, auto-fit grids) plus a media query for anything that needs to change on small screens. Here, @media (max-width: 600px) makes the heading smaller and tidies the menu spacing.

To test, open the page in Chrome, press F12 and click the phone icon (device toolbar), or drag the browser window narrow.

From the authorMost first websites I'm asked to fix look fine on a laptop and broken on a phone, and nine times out of ten the viewport meta tag is missing. Add it to every page before anything else, then check each page on a real phone before you publish. — Faisal Nadeem

Step 7: Add JavaScript (optional)

A simple website doesn't need JavaScript. When you want something interactive, put the code in script.js and link it in the head with defer, as every page here already does. This one keeps the year in the footer up to date:

// Keep the year in the footer up to date
document.getElementById("year").textContent = new Date().getFullYear();

See how to link JavaScript to HTML for where scripts go and why defer matters.

Try the home page in the editor

The online editor works with one file at a time, so this version has the CSS, JavaScript and image placed inside the HTML. Change the colours in the <style> section and watch the page update:

Open this example in the editor →

The htmlonline.dev editor with the bakery home page code on the left and the styled page in the live preview on the right
The single-file version of the home page in the htmlonline.dev editor.

Step 8: Publish your website

To put the site online, upload the whole folder to a web host. Free options that work with plain HTML and CSS:

HostHow you uploadGood for
GitHub PagesPush the folder to a GitHub repository and turn on PagesFree, reliable, custom domains
Netlify or Cloudflare PagesDrag and drop the folder in the dashboard, or connect a repositoryQuick setup, free HTTPS
Your own web hostUpload with the control panel's file manager or FTP into public_htmlIf you already pay for hosting or email

Whichever you choose, index.html must be at the top of the uploaded folder, and file names must match the links exactly, including upper and lower case.

Checklist before you publish

  • Every page has its own <title> and meta description.
  • Every image has alt text, and photos are compressed.
  • Every menu link opens the right page, and email and phone links work.
  • The pages pass the HTML validator without errors.
  • Each page looks right on a phone.

Frequently asked questions

How do I make a website using HTML?

Create a folder with an index.html file, write the page in HTML, add more pages and link them with <a href>, style them from one linked style.css file, then upload the folder to a web host.

Can I make a website with only HTML?

Yes, a page with only HTML works, but it looks plain. CSS is what adds colours, fonts and layout, so almost every website uses both.

What do I need to make a website with HTML?

A text editor (VS Code, Notepad or the online HTML editor) and a web browser. Hosting to publish the site can be free.

How long does it take to make a website with HTML?

A simple 3-page site like the one in this guide takes a beginner a few hours. Learning enough HTML and CSS to build your own designs comfortably usually takes a few weeks of practice.

How do I make my HTML website public?

Upload the folder to a host such as GitHub Pages, Netlify or Cloudflare Pages. They give you a public address, and you can connect your own domain later.

Do I need JavaScript to make a website?

No. HTML and CSS are enough for most informational websites. Add JavaScript only for interactive features.

Keep going