HTML Form How to - Add red border around error class








Question

We would like to know how to add red border around error class.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.error input {<!--from  w  w  w  .j  av a 2 s .  c  o m-->
  border-style: solid;
  border-color: #c00;
  border-width: 2px;
}

input[type=checkbox] {
  background: transparent;
  border: 0;
  margin-top: 2px;
}
</style>
</head>
<body>
  <div class="error">
    <input type='checkbox'><input type='text'>
  </div>
</body>
</html>

The code above is rendered as follows: