How to Create a Simple Website with HTML and CSS

Creating a website is an essential skill in the digital age, whether you want to showcase your portfolio, start a blog, or create a personal webpage.

With HTML and CSS, you can build a simple, functional, and visually appealing website without the need for advanced tools or complex programming languages.

This guide will take you through every step of creating a basic website from scratch, explaining concepts in detail so even beginners can follow along.

By the end of this guide, you will have a fully functional website and the confidence to explore more advanced techniques. Let’s get started!

Understanding the Basics

Before diving into the creation process, it’s essential to understand the two foundational technologies we’ll use:

What is HTML?

HTML (HyperText Markup Language) is the standard language for creating webpages.

It structures the content of a webpage using elements like headings, paragraphs, images, links, and more.

Think of HTML as the skeleton of your website, providing the layout and defining what each part of the page does.

What is CSS?

CSS (Cascading Style Sheets) is used to style HTML content. It controls the colors, fonts, spacing, layout, and overall design of the website.

If HTML is the skeleton, CSS is the skin, clothes, and makeup that make the website visually appealing.


Step 1: Planning Your Website

Before you start coding, spend some time planning your website.

Consider the following:

  1. Purpose: Decide on the goal of your website. Is it a personal portfolio, a blog, or a simple informational site?
  2. Content: Outline the sections you want, such as a home page, about page, and contact page.
  3. Design: Sketch a layout. Think about where you want the header, navigation bar, content sections, and footer to appear.

Planning ensures you have a clear vision, making the development process smoother and more efficient.


Step 2: Setting Up Your Environment

To start building your website, you’ll need a text editor and a browser.

Here’s how to set up:

Choosing a Text Editor

A text editor is where you write your code.

Popular options include:

  • VS Code: Free and feature-rich.
  • Sublime Text: Lightweight and fast.
  • Notepad++: Beginner-friendly.

Creating Your Project Folder

Organize your files by creating a folder for your project. For example, name it MyWebsite. Inside this folder, you’ll store all HTML, CSS, and image files.

Opening Your Browser

You’ll use a browser like Chrome, Firefox, or Edge to view and test your website.


Step 3: Writing the HTML

Create an HTML File

In your project folder, create a new file and name it index.html. This is the main file that browsers will load first.

Add the Basic HTML Structure

Every HTML document requires a basic structure.

Copy the following code into your index.html file:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Simple Website</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <header>
        <h1>Welcome to My Website</h1>
        <nav>
            <ul>
                <li><a href="#home">Home</a></li>
                <li><a href="#about">About</a></li>
                <li><a href="#contact">Contact</a></li>
            </ul>
        </nav>
    </header>
    <main>
        <section id="home">
            <h2>Home</h2>
            <p>This is the home section of the website.</p>
        </section>
        <section id="about">
            <h2>About</h2>
            <p>This section is all about the website or yourself.</p>
        </section>
        <section id="contact">
            <h2>Contact</h2>
            <p>Get in touch through this section.</p>
        </section>
    </main>
    <footer>
        <p>&copy; 2024 My Simple Website</p>
    </footer>
</body>
</html>

Explanation of Code

  • <!DOCTYPE html>: Declares the document as an HTML5 file.
  • <html>: The root element that contains all HTML code.
  • <head>: Contains metadata like the title and links to stylesheets.
  • <body>: Contains the visible content of the webpage.
  • <header>, <main>, <footer>: Semantic elements that structure your page.
  • <nav>: Holds navigation links.
  • <section>: Groups content into sections like Home, About, and Contact.

ALSO READ: How to Choose the Best Programming Language for Your Project


Step 4: Styling with CSS

Website
Styling with CSS

Create a CSS File

In your project folder, create another file named styles.css. This file will contain all the styles for your website.

Add Basic Styles

Add the following CSS code to styles.css:

/* General Styles */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

/* Header Styles */
header {
    background: #333;
    color: #fff;
    padding: 1rem 0;
    text-align: center;
}

header h1 {
    margin: 0;
}

nav ul {
    list-style: none;
    padding: 0;
    display: flex;
    justify-content: center;
    background: #444;
}

nav ul li {
    margin: 0 15px;
}

nav ul li a {
    color: #fff;
    text-decoration: none;
}

/* Section Styles */
main {
    padding: 2rem;
    background: #f4f4f4;
}

section {
    margin-bottom: 2rem;
}

/* Footer Styles */
footer {
    background: #333;
    color: #fff;
    text-align: center;
    padding: 1rem 0;
}

Explanation of CSS Code

  • body: Sets default styles for the entire page, including font and spacing.
  • header: Styles the top section with a dark background and white text.
  • nav ul: Creates a horizontal navigation bar.
  • main: Adds padding to the main content area.
  • footer: Styles the bottom section similar to the header.

Step 5: Viewing Your Website

  1. Save both index.html and styles.css.
  2. Open your index.html file in a browser by double-clicking it.
  3. You should see your styled website with a header, navigation bar, content sections, and footer.

Step 6: Enhancing Your Website

Adding Images

You can add images using the <img> tag. For example:

<img src="path-to-image.jpg" alt="Description">

Adding Links

Use the <a> tag to link to other pages or external websites:

<a href="https://example.com">Visit Example</a>

Creating a Contact Form

Add a simple form to the contact section:

<form action="submit_form.php" method="post">
    <label for="name">Name:</label>
    <input type="text" id="name" name="name" required>

    <label for="email">Email:</label>
    <input type="email" id="email" name="email" required>

    <label for="message">Message:</label>
    <textarea id="message" name="message" required></textarea>

    <button type="submit">Send</button>
</form>

ALSO READ: How to Start a Career in Web Development


Step 7: Publishing Your Website

Using GitHub Pages

  1. Create a free GitHub account and upload your project files.
  2. Enable GitHub Pages in your repository settings.
  3. Your website will be live at https://username.github.io/repository-name.

Other Hosting Options

  • Netlify
  • Vercel
Photo of author

Team Wdroyo

Wdroyo.net is your go-to platform for insightful articles across diverse topics, including Business, Finance, Technology, Health & Fitness, Home Improvement, and Gaming. Explore expert advice, trends, and practical tips to enhance your knowledge and enrich daily life.

Leave a Comment