Add a background color to the form input with CSS

To add background color to the form input, use the background-color property.

You can try to run the following code to implement the background color property to form


Live Demo

<!DOCTYPE html>
         input[type=text] {
            width: 100%;
            padding: 10px 15px;
            margin: 5px 0;
            box-sizing: border-box;
            background-color: gray;
      <p>Fill the below form,</p>
         <label for = "subject">Subject</label>
         <input type = "text" id = "subject" name = "sub">
         <label for = "student">Student</label>
         <input type = "text" id = "student" name = "stu">

Updated on: 23-Jun-2020

7K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started