How to adjust the alignment of a <th>?

Asked

Viewed 2,754 times

1

I would like to know how I do to adjust the alignment of a Table Heading <th>? I do not know if it is possible to do this procedure as it is done for <tr> or <td>. I want to be able to do this to align the contents of each cell of my table with the text of <th>.

1 answer

3


You can line up with CSS and nothing else, look:

table, th, td {
    border: 1px solid black;
}

th, td{
  width: 100px;
}

th{
  text-align: left;
}
<table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table>

Try changing the .text-align and see how it changes

Browser other questions tagged

You are not signed in. Login or sign up in order to post.