Autocodewizard Logo Project 2 Creating a Multi-Page Website - Autocodewizard Ebook: HTML & CSS Foundations

Chapter 13: Project 2 – Creating a Multi-Page Website

In this project, you’ll expand on your skills by creating a simple multi-page website. We’ll set up a basic site structure with multiple linked pages, including a home page, an about page, and a contact page. This project will introduce you to basic navigation and help you understand how to link pages together.

Setting Up the Folder Structure

First, create a folder for your website project. Inside this folder, create individual HTML files for each page and a separate CSS file for styling.

        my-website/
        ├── index.html
        ├── about.html
        ├── contact.html
        └── styles.css
        
                

Creating the Home Page (index.html)

Start with the main page of your website, index.html, which will serve as the home page. Add a navigation menu at the top to link to other pages.

        <!DOCTYPE html>
        <html lang="en">
            <head>
                <meta charset="UTF-8">
                <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <title>Home - My Website</title>
                <link rel="stylesheet" href="styles.css">
            </head>
            <body>
                <header>
                    <nav>
                        <a href="index.html">Home</a>
                        <a href="about.html">About</a>
                        <a href="contact.html">Contact</a>
                    </nav>
                </header>
        
                <main>
                    <h1>Welcome to My Website</h1>
                    <p>This is the home page of my multi-page website project.</p>
                </main>
                
                <footer>© 2024 My Website</footer>
            </body>
        </html>
        
                

Creating the About Page (about.html)

Now, create the about.html page, which will include a brief introduction about you or the site. Keep the navigation consistent across all pages.

        <!DOCTYPE html>
        <html lang="en">
            <head>
                <meta charset="UTF-8">
                <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <title>About - My Website</title>
                <link rel="stylesheet" href="styles.css">
            </head>
            <body>
                <header>
                    <nav>
                        <a href="index.html">Home</a>
                        <a href="about.html">About</a>
                        <a href="contact.html">Contact</a>
                    </nav>
                </header>
        
                <main>
                    <h1>About Me</h1>
                    <p>Welcome to the About page. Here, you can learn more about me and the purpose of this website.</p>
                </main>
                
                <footer>© 2024 My Website</footer>
            </body>
        </html>
        
                

Creating the Contact Page (contact.html)

The contact.html page will include a form for visitors to reach out. This is a simple contact form with fields for name, email, and message.

        <!DOCTYPE html>
        <html lang="en">
            <head>
                <meta charset="UTF-8">
                <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <title>Contact - My Website</title>
                <link rel="stylesheet" href="styles.css">
            </head>
            <body>
                <header>
                    <nav>
                        <a href="index.html">Home</a>
                        <a href="about.html">About</a>
                        <a href="contact.html">Contact</a>
                    </nav>
                </header>
        
                <main>
                    <h1>Contact Me</h1>
                    <form action="/submit" method="post">
                        <label for="name">Name:</label>
                        <input type="text" id="name" name="name" placeholder="Your Name">
        
                        <label for="email">Email:</label>
                        <input type="email" id="email" name="email" placeholder="Your Email">
        
                        <label for="message">Message:</label>
                        <textarea id="message" name="message" rows="4" placeholder="Your Message"></textarea>
        
                        <button type="submit">Send Message</button>
                    </form>
                </main>
        
                <footer>© 2024 My Website</footer>
            </body>
        </html>
        
                

Adding Basic Styling with CSS (styles.css)

Use a single CSS file to style all pages, ensuring consistency across the site.

        /* Basic styling for multi-page website */
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            color: #333;
            margin: 0;
            padding: 0;
        }
        
        header {
            background-color: #333;
            color: #ffffff;
            padding: 10px;
            text-align: center;
        }
        
        nav a {
            color: #ffffff;
            margin: 0 10px;
            text-decoration: none;
        }
        
        nav a:hover {
            text-decoration: underline;
        }
        
        main {
            max-width: 800px;
            margin: 20px auto;
            padding: 20px;
            background-color: #ffffff;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        }
        
        footer {
            text-align: center;
            padding: 10px;
            font-size: 0.875rem;
            color: #666666;
        }
        
                

Experimenting with Your Multi-Page Website

Now that you’ve created a basic multi-page website, you can experiment with adding more pages or enhancing the design. Try different layouts, colors, and styles to make your website unique. This project is a great way to practice HTML and CSS and to get comfortable working with a multi-page structure.