Table alignment here doesn’t mean reversing the tables up and down. It means to set the position of the text inside the columns <th> tag and rows <td> tag.
The two common table alignments are as follows:
Let's understand them one by one and learn how to implement them.
Horizontal alignment is known as the text-align property in <th> and <td> elements to the right, left, and center.
text-align:right;text-align:left;text-align:center;Note: Default values of the table head
<th>are center-aligned and the values of table data<td>cells are left-aligned.
Vertical alignment is known as the vertical-align property in CSS. With this, we can set the vertical alignment of the content of <th> and <td> tags as top, bottom, and middle.
Note: Default values of table head and table data contents are middle aligned.
vertical-align: topvertical-align: bottomvertical-align: middleFor this, we have to construct a table first. The code for constructing a table is given below:
2px, solid, and blue respectively.80%. This can be changed according to the needs and screen sizes.vertical-align is equal to the bottom meaning the content will be at the bottom of the cell.text-align: right;).stye tag before the head tag.