HTML Project - Creating a Basic Contact Form


Create a basic contact form using HTML, including fields for name, email, and message. This step-by-step guide is ideal for those looking to add a contact form to their website.


Step 1: Create an HTML file

Create a new file and name it contact.html.


Step 2: Add the basic HTML structure

Set up the basic structure like below.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Contact Form</title>
</head>
<body>
    <!-- Content will go here -->
</body>
</html>


Step 3: Create a Form

Inside the <body> tag, create a form with a few input fields for the name, email, and message.

<body>
    <h1>Contact Us</h1>
    <form action="#" method="post">
        <label for="name">Name:</label><br>
        <input type="text" id="name" name="name"><br><br>

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

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

        <input type="submit" value="Submit">
    </form>
</body>


Final Code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Contact Form</title>
</head>
<body>
    <h1>Contact Us</h1>
    <form action="#" method="post">
        <label for="name">Name:</label><br>
        <input type="text" id="name" name="name"><br><br>

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

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

        <input type="submit" value="Submit">
    </form>
</body>
</html>