HTML Element Style How to - Add Shadow to Tables








Question

We would like to know how to add Shadow to Tables.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
<!--from w w  w  .  ja v  a2  s  .c om-->
.main-body td.header {
  text-align: left;
  padding-left: 50px;
  color: white;
  font-size: 50px;
}

.main-body td.header2 {
  text-align: right;
  padding-right: 30px;
  color: white;
  font-size: 30px;
}

.nopad {
  border-spacing: 0px;
  padding: 0px;
}

table.header {
  background-color: #151515;
  width: 100%;
}

.main-body {
  border-spacing: 0px;
  border-collapse: separate;
  color: #202020;
  margin-left: auto;
  margin-right: auto;
  width: 600px;
  background-color: #d2ffdc;
  box-shadow: 10px 10px 10px #101010;
}

table, tr, td {
  border-collapse: collapse;
}

table.header2 {
  background-color: #151515;
  width: 100%;
  border-radius: 20px;
  padding: 0;
  margin: 0;
}
</style>
</head>
<body>
  <table class="main-body round">
    <tr>
      <td class="nopad">asdf
      </td>
    </tr>
    <tr>
      <td>Line 1</td>
    </tr>
    <tr>
      <td>Line 2</td>
    </tr>
    <tr>
      <td>Line 3</td>
    </tr>
    <tr>
      <td>Line 4</td>
    </tr>
  </table>
</body>
</html>

The code above is rendered as follows: