How to Build a Simple Contact Form Using HTML, CSS, and JavaScript (Beginners Guide)
A contact form is the little box you see on websites where you can type your name, email, message, and hit Send.
And guess what? Building one is much easier than you might think.
We’re going to create a simple form, make it look nice, and add a bit of JavaScript so it behaves properly. Even if you’re new or feel “not smart enough for coding,” trust me—you can do this.
Let’s get started.
1. Step One: Create Your Project Folder
You already know the drill from the previous tutorial:
Inside it, create:
That’s our starting point.
2. Step Two: Write the HTML Form
Open index.html and add:
Explanation
-
<form>holds all the input fields -
<input>receives text like name and email -
<textarea>is for longer messages -
The
<button>will submit the form -
id="status"will display messages like “Sent successfully!”
Simple and clean.
3. Step Three: Make It Look Nice with CSS
Open style.css and add:
Explanation
-
The form is centered to look clean
-
Inputs have padding and rounded corners
-
Button has a friendly color
-
Gap makes spacing easy
Looking professional already!
4. Step Four: Add JavaScript Validation
Open script.js and add:
Explanation
-
We prevent the page from reloading
-
Check if all fields are filled
-
Check if email looks valid
-
Show a friendly success message
-
Reset the form after submission
This is exactly how real websites handle form validation.