In this example you will learn, how to create a contact form with CSS. Following is the code to create a contact form using CSS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | <!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> |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.