HTML Form How to - Add shadow to textarea when having focus








Question

We would like to know how to add shadow to textarea when having focus.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
input {<!--from  w  w w  . ja  v  a 2s .c  om-->
  width: 200px;
  height: 30px;
  border-radius: 3px 3px 3px;
  transition: all 0.3s;
  -webkit-transition: all 0.3s;
  -moz-transition: all 0.3s;
  margin: 5px;
  border: 1px solid #ddd;
}

input:focus {
  box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.2);
  outline: 0;
}
</style>
</head>
<body>
  <input type="text" />
</body>
</html>

The code above is rendered as follows: