HTML Form How to - Add border to textarea with active and focus








Question

We would like to know how to add border to textarea with active and focus.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
textarea {<!--from   ww w .jav  a  2  s.  c o m-->
  resize: none;
  border: none;
  background: #eee;
}

textarea:focus, textarea:active {
  resize: both;
  border: 1px solid #000;
}
</style>
</head>
<body>
  <textarea></textarea>
</body>
</html>

The code above is rendered as follows: