td text-align: center; : td text « Tags « HTML / CSS






td text-align: center;

   





<html>
<head><title>Tables</title>
<style type="text/css">
td {
  text-align: center;
  font-weight: bold;
}

table {
  background-color: blue;
  color: white;
}

caption {
  background-color: red;
  color: yellow;
  font-weight: bold;
}

th {
  background-color: gold;
  color: navy
}

td.center {
  background-color: white;
  color: black;
}
</style></head>

<body>
<table>
    <caption>How to Use Tables</caption>
  <tr>
      <th>Col 1</th>
      <th>Col 2</th>
      <th>Col 3</th>
  </tr>
  <tr>
      <td>X</td>
      <td>X</td>
      <td>X</td>
  </tr>
  <tr>
      <td>X</td>
      <td class="center">X</td>
      <td>X</td>
  </tr>
  <tr>
      <td>X</td>
      <td>X</td>
      <td>X</td>
  </tr>
</table>
</body>
</html>

   
    
  








Related examples in the same category

1.'abbr' sets the abbreviated text for the cell and replace the cell contents
2.'ch' is a character that specifies the alignment of subsequent text
3.td text-align: center; and border
4.Text Indent
5.td text-align: left;
6.td text-align: right;
7.td text-align: justify;
8.td text-transform: lowercase;
9.td border: thin solid black;text-align: center;font-weight: bold;