Recent Posts

Responsive Advertisement

html coding - Part 7 - HTML TABLES

 Next topic: HTML Tables.

HTML Tables
Tables are used to display data in a structured format.
Table Syntax
HTML
<table>
	<tr>
		<th>Header 1</th>
		<th>Header 2</th>
	</tr>
	<tr>
		<td>Cell 1</td>
		<td>Cell 2</td>
	</tr>
</table>
Table Elements
  • <table>: Defines the table
  • <tr>: Defines a table row
  • <th>: Defines a table header cell
  • <td>: Defines a table data cell
Table Attributes
  • border: Specifies the table border width
  • cellpadding: Specifies the space between cells
  • cellspacing: Specifies the space between cells and borders
Example Table
HTML
<table border="1" cellpadding="5" cellspacing="0">
	<tr>
		<th>Name</th>
		<th>Age</th>
	</tr>
	<tr>
		<td>John</td>
		<td>25</td>
	</tr>
	<tr>
		<td>Jane</td>
		<td>30</td>
	</tr>
</table>
Table Best Practices
  • Use tables for tabular data, not for layout.
  • Use <th> for header cells and <td> for data cells.
  • Use border, cellpadding, and cellspacing attributes to style the table.

Post a Comment

0 Comments


Comments

Ad Code

Responsive Advertisement