Responsive Contact Form using HTML & CSS

Responsive Contact Form using HTML & CSS


Hello developers, today in this blog, you'll learn how to create a Responsive Contact Form using HTML & CSS.

A contact form on a website allows visitors to contact the owner of the site or the person who is maintaining the website. To contact the owner of the website or the person who is maintaining the site, the visitors have to fill the form with the details like Name, Email, Country, and Subject. In the Subject, the information that the visitor wishes to convey to the owner can be texted.

After the visitor fills this form, they can give submit button which will send the information to the owner of the site. The details filled by the visitor in the form will be received by the owner of the site.

In this program (Responsive Contact Form), on the webpage, the linear background is used. To make the contact form responsive, we have used the CSS media query property. The Subject text box in this contact form is adjustable.

The source code of this Responsive Contact Form is given below, if you want the source code of this program, you can copy it. You can use this Responsive Contact Form with your creativity and can take this project to the next level.

Responsive Contact Form using HTML & CSS [Source Code]

To make this website, you would like to make two files: an HTML file & a CSS file. First, create an HTML file with the name of index.html and remember, you have to create a file with a .html extension.

<!DOCTYPE html> <html> <head> <title>Responsive contact form</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <form action="/action_page.php"> <div class="row"> <div class="col-25"> <label for="fname">Name</label> </div> <div class="col-75"> <input type="text" id="fname" name="firstname" placeholder="Your name.." autocomplete="off"> </div> </div> <div class="row"> <div class="col-25"> <label for="lname">Email</label> </div> <div class="col-75"> <input type="email" id="lname" name="lastname" placeholder="Your Email.."autocomplete="off"> </div> </div> <div class="row"> <div class="col-25"> <label for="country">Country</label> </div> <div class="col-75"> <select id="country" name="country" autocomplete="off"> <option value="australia">India</option> <option value="canada">Canada</option> <option value="usa">USA</option> </select> </div> </div> <div class="row"> <div class="col-25"> <label for="subject">Subject</label> </div> <div class="col-75"> <textarea id="subject" name="subject" placeholder="Write something.." style="height:200px"></textarea> </div> </div> <div class="row"> <input type="submit" value="Submit"> </div> </form> </div> <div class="credit">Made with <span style="color:tomato">❤</span> by <a href="https://www.learningrobo.com/">Learning Robo</a></div> </body> </html>
CSS provides style to an HTML page. To make the page attractive and page responsive create a CSS file with the name style.css and remember that you have to make a file with a .css extension.


* {
    box-sizing: border-box;
  }
  body{
    background-color: #85FFBD;
    background-image: linear-gradient(45deg, #85FFBD 0%, #FFFB7D 100%);
    font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
    
  }
  input[type=text], select, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #85FFBD;
    border-radius: 4px;
    resize: vertical;
    color:#fff;
    background-color: transparent;
  }

  input[type=email] {
    width: 100%;
    padding: 12px;
    border: 1px solid #85FFBD;
    border-radius: 4px;
    resize: vertical;
    color:#fff;
    background-color: transparent;
  }
  
  label {
    padding: 12px 12px 12px 0;
    display: inline-block;
  }
  
  input[type=submit] {
    background-color: #85FFBD;
    background-image: linear-gradient(45deg, #85FFBD 0%, #FFFB7D 100%);
    color: #000;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    float: right;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  }
  
  input[type=submit]:hover {
    background-color: #45a049;
  }
  
  .container {
    border-radius: 10px;
    background-color: #202124;
    padding: 20px;
    max-width:800Px;
    margin: 85px auto;
    color:#fff;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  }
  
  .col-25 {
    float: left;
    width: 25%;
    margin-top: 6px;
  }
  
  .col-75 {
    float: left;
    width: 75%;
    margin-top: 6px;
  }
  
  /* Clear floats after the columns */
  .row:after {
    content: "";
    display: table;
    clear: both;
  }
  
  /* Responsive layout - when the screen is less than 600px wide, make the two columns stack on top of each other instead of next to each other */
  @media screen and (max-width: 600px) {
    .col-25, .col-75, input[type=submit] {
      width: 100%;
      margin-top: 0;
    }
  }

  
  .credit{


    text-align: center;
    color: #000;
    font-weight: 900;
    font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}

.credit a{
    text-decoration: none;
    color:#202124;
    font-weight: bold;
}   
We hope you would like this Responsive Contact Form using HTML & CSS.

Thank you for reading our blog. If you face any problem in creating this Responsive Contact Form using HTML & CSS, then contact us or comment us. We’ll try to provide a solution to your problem as soon as possible.

Thank you
Learning robo team

Post a Comment

Thank you
Learning robo team

Post a Comment (0)

Previous Post Next Post
Learning Robo says...
code copied
Welcome