📄
Create a Contact Form 📧
Beginner
120 XP
40 min
Lesson Content
Create a Contact Form 📧
Build a professional contact form that businesses use to collect customer inquiries.
Form Structure
<form action="/submit" 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 Message</button>
</form>Form Best Practices
- Use proper input types (email, tel, etc.)
- Add labels for accessibility
- Use required attribute for mandatory fields
- Include placeholder text
Example Code
Create a contact form with validation
<form> <label for="name">Your 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>
Expected Output:
Contact form with name, email, and message fields
Study Tips
- •Read the theory content thoroughly before practicing
- •Review the example code to understand key concepts
- •Proceed to the Practice tab when you're ready to code