DEV Community

Codewithrandom Blogs
Codewithrandom Blogs

Posted on

How to Create Contact Form using HTML and CSS

Today we are going to create a contact form using Html and Css but first, let me introduce what exactly a contact form is.
A Contact Form is a short web-based form published on a website. Any visitor can fill out the form and submit it to send a message to the site owner.
Publishing a contact form makes it easy for new customers to get in touch.

HTML Code For Contact Form

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<div id="main">
<h2>Contact Us</h2>
<form enctype="multipart/form-data" method="POST">
placeholder="Enter Your Name"
placeholder="Enter Your Email"
<div id="numb">
<select name="telcode" width="5">
<option selected>+91</option>
placeholder="Contact Number"
<textarea cols="20" rows="6" id="msg" name="msag" placeholder="Enter a Message"> </textarea>
<input id="submit" type="submit" value="Send Message" />
Enter fullscreen mode Exit fullscreen mode

This is the basic structure of our Contact form but this is not looking good as you see, so let's style it using css.

CSS Code For Contact Form

* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "gilroy";
body {
height: 100%;
width: 100%;
background-image: url("");
background-position: center;
background-size: cover;
#main {
height: 500px;
width: 500px;
background-color: rgba(100, 148, 237, 0.103);
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 2%;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
box-shadow: 7px 7px 5px rgba(0, 0, 0, 0.815);
h2 {
color: white;
text-shadow: 0px 2px 4px black;
font-weight: bold;
letter-spacing: 4px;
#msg {
width: 250px;
margin-left: 5%;
margin-top: 3%;
background: transparent;
#submit {
padding: 8px 15px;
background-color: #0a64ce;
color: white;
margin: 3% 25%;
select option,selected{
color: black;
font-size: 30px;
select {
Padding: 20px;
margin-top: 3%;
margin-left: 5%;
height: 35px;
background: transparent;
color: #ffff;
input#mobno {
margin-left: 2%;
::placeholder {
color: #ffff;
font-size: 20px;
Enter fullscreen mode Exit fullscreen mode

written by @cannycoder_7

Thanks For Reading!

Oldest comments (0)