Categories
Web development

CSS Contact Form

Today I would like to show you an example of a handy thing, which you can use on your web page – the Contact Form.

You can learn how to create a contact form with CSS. 

CSS Contact Form

Example:

Let’s start from the beginning…

Step 1: Add HTML

Use the <form> element to process the input. Then add inputs (with a matching label) for each field:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="container-1">
  <form action="">
    <label for="fname">First Name</label>
    <input type="text" id="first-name" name="firstname" placeholder="Your name..">

    <label for="lname">Last Name</label>
    <input type="text" id="last-name" name="lastname" placeholder="Your last name..">

    <label for="country">Country</label>
    <select id="country" name="country">
      <option value="australia">Australia</option>
      <option value="canada">Canada</option>
      <option value="usa">USA</option>
    </select>

    <label for="subject">Subject</label>
    <textarea id="subject" name="subject" placeholder="Write something.." style="height:200px"></textarea>

    <input type="submit" value="Submit">
  </form>
</div>
</body>
</html>

Step 2: Add CSS

body {font-family: Arial, Helvetica, sans-serif;}
* {box-sizing: border-box;}

input[type=text], select, textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #333;
  border-radius: 4px;
  box-sizing: border-box;
  margin-top: 6px;
  margin-bottom: 16px;
  resize: vertical;
}

input[type=submit] {
  background-color: #e9c46a;
  color: #333;
  font-weight: bold;
  padding: 12px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

input[type=submit]:hover {
  background-color: #e76f51;
}

.container-1 {
  border-radius: 5px;
  background-color: #2a9d8f;
  padding: 20px;
}

Enjoy coding!

Read also:

CSS Buttons

CSS Border Corner Shape: Scoop, Notch, Square-Cut

CSS Blurred Background Image