CSS Forms


    Types of form inputs in CSS

  • input[type=text]-to style text fields
  • input[type=number]-to style number fields
  • input[type=password]-to style password fields

Making simple form in CSS

<!DOCTYPE html>
<html>
<head>
<title>
CSS FORMS
</title>
</head>
<body>
<form>
Enter your name:
<input type="text" name="name" value="ANKIT">
Enter your number:
<input type="number" name="number" value="9051320061">
</form>
</body>
</html>

Output:

Enter your name:



Enter your number:

Styling simple CSS form

<!DOCTYPE html>
<html>
<head>
<style>
input[type=text]{
width:100%;
padding:15px;
color:white;
border:1px solid red;
background-color:dimgrey;
border-radius:8px;
}
</style>
<title>
CSS FORMS
</title>
</head>
<body>
<form>
Enter your name:
<input type="text" name="name" value="ANKIT">
Enter your number:
<input type="number" name="number" value="9051320061">
</form>
</body>
</html>

Output:

Enter your name:



Enter your number:

Adding submit button in CSS form

Adding simple CSS submit button

<!DOCTYPE html>
<html>
<head>
<style>
input[type=text]{
width:100%;
padding:15px;
color:white;
border:1px solid red;
background-color:dimgrey;
border-radius:8px;
}
</style>
<title>
CSS FORMS
</title>
</head>
<body>
<form>
Enter your name:
<input type="text" name="name" value="ANKIT">
Enter your number:
<input type="number" name="number" value="9051320061">
<button type="submit" value="submit">
Click here to submit your form</button>
</form>
</body>
</html>

Output:

Enter your name:



Enter your number:



Styling simple CSS submit button

<!DOCTYPE html>
<html>
<head>
<style>
input[type=text]{
width:100%;
padding:15px;
color:white;
border:1px solid red;
background-color:dimgrey;
border-radius:8px;
}
button{
width:100%;
background-color: blue;
border-radius: 8px;
color:white;
height:35px;
border:1px solid black;
}
</style>
<title>
CSS FORMS
</title>
</head>
<body>
<form>
Enter your name:
<input type="text" name="name" value="ANKIT">
Enter your number:
<input type="number" name="number" value="9051320061">
<button type="submit" value="submit">
Click here to submit your form
</button>
</form>
</body>
</html>

Output:

Enter your name:



Enter your number: