HTML Element Style How to - Add shadow to a div








Question

We would like to know how to add shadow to a div.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#main {<!--from w w w.j  ava  2  s .c o m-->
  height: 100px;
  width: 200px;
}

.shadow {
  box-shadow: 1px 1px 1px 1px #888888;
}
</style>
</head>
<body>
  <div id='main' class="shadow"></div>
</body>
</html>

The code above is rendered as follows: