How to create a contact form with CSS?


Following is the code to create a contact form using CSS −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {box-sizing: border-box;}
body{
   font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
label{
   font-size: 15px;
}
input[type=text],textarea {
   width: 100%;
   padding: 12px;
   border: 1px solid #ccc;
   border-radius: 4px;
   box-sizing: border-box;
   margin-top: 6px;
   margin-bottom: 16px;
}
input[type=submit] {
   background-color: #4CAF50;
   color: white;
   padding: 12px 20px;
   border: none;
   border-radius: 4px;
   cursor: pointer;
}
input[type=submit]:hover {
   background-color: #45a049;
}
form {
   border-radius: 5px;
   background-color: #feffc6;
   padding: 20px;
}
</style>
</head>
<body>
<h1 style="text-align:center">Contact Form</h1>
<form>
<label for="fname">First Name</label>
<input type="text" id="fname" name="firstname" placeholder="Enter your firstname">
<label for="lname">Last Name</label>
<input type="text" id="lname" name="lastname" placeholder="Enter your surname">
<label for="email">Email Id</label>
<input type="text" id="email" name="Email" placeholder="Enter your emailId">
<label for="contact">Contact</label>
<textarea id="contact" name="contact" placeholder="Write your message here"
style="height:200px"></textarea>
<input type="submit" value="Submit">
</form>
</body>
</html>

Output

This will produce the following output −

Updated on: 08-Apr-2020

320 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements