HTML Form How to - Define CSS only for enabled input








Question

We would like to know how to define CSS only for enabled input.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
input[type="text"].disabled {
  background: blue;
}<!--from ww  w.  j a v  a 2s  .c  o m-->
</style>
</head>
<body>
  <input type="text" />
  <input type="text" class="disabled" />
</body>
</html>

The code above is rendered as follows: