Add space inside a form’s text field with CSS


To add space inside a form’s text field, use the CSS padding property.

You can try to run the following code to achieve this:

Example

Live Demo

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

Updated on: 23-Jun-2020

9K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements