CSS Property Value How to - text-align: right;








Question

We would like to know how to text-align: right;.

Answer


<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of setting horizontal alignment of table content</title>
<style type="text/css">
table {<!-- w  ww  .  ja v a  2 s  . com-->
  width: 300px;
  text-align: left;
}

table caption {
  text-align: right;
}
</style>
</head>
<body>
  <table border="1">
    <caption>User Info</caption>
    <tr>
      <th>Name</th>
      <th>Email</th>
    </tr>
    <tr>
      <td>John</td>
      <td>john@mail.com</td>
    </tr>
  </table>
</body>
</html>

The code above is rendered as follows: