How to Build a Static Website using HTML and CSS alone.

Zepher
5 min readDec 13, 2023

--

A static website is a website that has fixed content and does not require any programming languages to build. It is the easiest and cheapest form of website to create, and it is also secure and fast. Static websites are built using HTML, CSS, and JavaScript, which are the basic languages for web development.

In this blog post, I will show you how to build a simple static website using HTML and CSS alone. You will learn how to create the structure, style, and layout of your web page, and how to host it online using W3Schools Spaces.

What You Need to Know

To build a static website, you need to have some basic knowledge of HTML and CSS. HTML stands for Hyper Text Markup Language, and it is used to define the structure and content of your web page. CSS stands for Cascading Style Sheets, and it is used to set the appearance and layout of your web page, such as colors, fonts, margins, etc.

If you are new to HTML and CSS, you can learn them from W3Schools, which is a free online tutorial website that teaches web development. W3Schools also provides Spaces, which is a personal place where you can build and host your static website for free.

How to Create a Static Website

There are two ways to create a static website: coding from scratch or using a template. Coding from scratch means that you write the HTML and CSS code yourself, using a text editor or an online code editor. Using a template means that you use a ready-made HTML and CSS file that someone else has created, and you can modify it according to your needs.

In this blog post, I will show you how to code a static website from scratch, using W3Schools Spaces as an online code editor and web hosting provider. If you want to use a template, you can find many static website templates on W3Schools Spaces, and you can load them directly into the service.

Step 1: Create Your Account and Space

To use W3Schools Spaces, you need to create an account and a space. A space is a personal place where you can store your files and host your website. To create an account, you need to sign up with an email and a password. To create a space, you need to give it a name and a URL. For example, if your space is named my-website, your space URL is my-website.w3spaces.com.

To create your account and space, follow these steps:

  • Go to W3Schools Spaces and click on the “Sign up” button.
  • Enter your email and password, and click on the “Create account” button.
  • Click on the “Create a space” button in the top right corner.
  • Select the “Blank space” option and click on the “Continue” button.
  • Enter a name for your space and click on the “Continue” button.
  • You will see a summary of your space, with your space name, URL, and other information.

Step 2: Add Your Files

To create a static website, you need to have at least one HTML file and one CSS file. The HTML file is the main file that contains the content and structure of your web page. The CSS file is the file that contains the style and layout of your web page. You can also have other files, such as images, icons, fonts, etc., that you want to use on your website.

To add your files, follow these steps:

  • Click on the “Upload files” button on the right side of the space summary page.
  • Select the files that you want to upload from your computer, and click on the “Open” button.
  • You will see your files listed on the space file manager page.
  • Alternatively, you can create a new file by clicking on the “New file” button, and enter the file name and extension. For example, index.html or style.css.

Note that the file for your home page must be named index.html. This is the file that browsers will look for when they visit your website.

Step 3: Write Your Code

To write your code, you need to open your files and edit them using the online code editor. The code editor has syntax highlighting, auto-completion, and other features that make coding easier and faster. You can also preview your website in real time, by clicking on the “Preview” button on the top right corner.

To write your code, follow these steps:

  • Click on the file that you want to edit, and it will open in the code editor.
  • Write your HTML and CSS code, following the syntax and rules of the languages.
  • Save your changes by clicking on the “Save” button on the top left corner.
  • Preview your website by clicking on the “Preview” button on the top right corner.

Here is an example of a simple HTML and CSS code that you can use to create a static website:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Static Website</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>My Static Website</h1>
<p>This is a simple static website that I created using HTML and CSS.</p>
<p>It is hosted on W3Schools Spaces, which is a free service that lets you build and host your website online.</p>
<p>You can learn more about web development from W3Schools, which is a free online tutorial website.</p>
</div>
</body>
</html>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}

.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
h1 {
color: #333;
font-family: Arial, sans-serif;
font-size: 36px;
text-align: center;
}
p {
color: #666;
font-family: Arial, sans-serif;
font-size: 18px;
line-height: 1.5;
margin: 10px 0;
}

Step 4: Publish Your Website

To publish your website, you need to make your space public and share your space URL with others. Your space URL is the address that people can use to access your website on the internet. For example, if your space is named my-website, your space URL is my-website.w3spaces.com.

To publish your website, follow these steps:

  • Click on the “Settings” button on the top right corner of the space file manager page.
  • Click on the “Privacy” tab, and select the “Public” option.
  • Click on the “Save changes” button.
  • Copy your space URL from the space summary page, and share it with others.

You Made It!

Congratulations! You have successfully created and published your static website using HTML and CSS alone. You can now view your website on any browser, and update it anytime by editing your files on W3Schools Spaces.

If you want to learn more about web development, you can visit W3Schools, which has tutorials, examples, and exercises on HTML, CSS, JavaScript, and other web technologies. You can also explore other static website templates on W3Schools Spaces, and use them as inspiration or as a starting point for your own website.

I hope you enjoyed this blog post, and I hope you have fun creating your own static website. Happy coding!

--

--