Jump to: navigation, search

HTML Table Text Align

From w3cyberlearnings

Contents

HTML Table Align

We use the CSS to define the text align for the table cell.

Example 1 TRY-IT

In this example, we set the text align to left for all the cells in the table.

<style>	
	table {
		padding:8px;
		border-spacing: 3px;
	}
	
	th,td {	
   	        border:1px solid black;
	        padding:13px;
		text-align:left;
	}
</style>

Example 2 TRY-IT

This is similar to the first example, but we define the text align to right.

<style>
	table {
		padding:8px;
		border-spacing: 3px;
	}
	th,td {
	        border:1px solid black;
		padding:13px;
		text-align:right;
	}
</style>

Example 3 TRY-IT

This example, we set each individual cell.

<style>
	table {
		padding:8px;
		border-spacing: 3px;
	}
	th,td {
		padding:13px;
	        border:1px solid black;		
	}

	.righta {
		text-align:right;
	}
	.lefta {
		text-align:left;
	}
	.middlea {
		text-align: center;
	}
</style>

Related Link


Table
  1. HTML - Table
  2. HTML - Table Border
  3. HTML - Table Column
  4. HTML - Table Row
  5. HTML - Table Color
  6. HTML - Table Cell Spacing and Padding
  7. HTML - Text Align
  8. HTML - Text Vertical Align
  9. HTML - Table Caption and Summary
  10. HTML - Table thead, tbody, tfoot
  11. HTML - Inner Table
  12. HTML - Table Vertical Line
  13. HTML - Table Horizontal Line
Navigation
Web
SQL
MISC
References