Home > Web Front-end > CSS Tutorial > Add background color to form inputs using CSS

Add background color to form inputs using CSS

王林
Release: 2023-09-17 13:01:02
forward
1326 people have browsed it

使用 CSS 为表单输入添加背景颜色

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

You can try running the following code to implement the background color attribute of the form

Example

Live demonstration

<!DOCTYPE html>
<html>
   <head>
      <style>
         input[type=text] {
            width: 100%;
            padding: 10px 15px;
            margin: 5px 0;
            box-sizing: border-box;
            background-color: gray;
         }
      </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>
Copy after login

The above is the detailed content of Add background color to form inputs using CSS. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template