How to change alignment of each cell in html table?

by raven_corwin , in category: HTML & CSS , 2 months ago

How to change alignment of each cell in html table?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by addison , 2 months ago

@raven_corwin 

To change the alignment of each cell in an HTML table, you can use the "align" attribute within each or tag. Here's an example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<table>
  <tr>
    <th align="left">Header 1</th>
    <th align="center">Header 2</th>
    <th align="right">Header 3</th>
  </tr>
  <tr>
    <td align="left">Content 1</td>
    <td align="center">Content 2</td>
    <td align="right">Content 3</td>
  </tr>
  <tr>
    <td align="left">Content 4</td>
    <td align="center">Content 5</td>
    <td align="right">Content 6</td>
  </tr>
</table>


In the above example, the "align" attribute is used to specify the alignment for each cell. The values can be "left", "right", or "center". This will ensure that the content in each cell is aligned accordingly.