HTML Adding a table
To add a table in HTML, you can use the <table>, <tr>, <th>, and <td> tags. Here's an example code for a simple table with two rows and two columns:
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
In this example, <table> is the table tag, <tr> is the table row tag, <th> is the table header cell tag, and <td> is the table data cell tag. The first row contains the headers for the two columns, and the second row contains the data for the corresponding cells.
You can add more rows by repeating the <tr> tag, and more cells by repeating the <td> or <th> tag within a <tr> tag. Here's an example code for a table with three rows and three columns:
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
<tr>
<td>Data 4</td>
<td>Data 5</td>
<td>Data 6</td>
</tr>
</table>
You can also add attributes to the table, row, or cell tags to specify the width, height, border, alignment, and other properties of the table or its elements. For example:
<table border="1" width="500" align="center">
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
<tr>
<td>Data 4</td>
<td>Data 5</td>
<td>Data 6</td>
</tr>
</table>
This example sets the border width of the table to 1 pixel, the width of the table to 500 pixels, and the alignment of the table to the center of the page.
Comments
Popular Articles
Popular Tags
- #directive
- #Function
- #Json
- #Class
- #SASS
- #Form
- #Redirect
- #API
- #Special Characters
- #Special
- #Random
- #Generating
- #
- #Text
- #Ajax
- #URL
- #Encrypting
- #React
- #Show
- #timeAgo
- #PSR-4
- #Hide
- #DDOS Protection
- #DDOS
- #cURL
- #Logic For Displaying Posts
- #Error
- #Key
- #General Error
- #1364 Field
- #Abbreviation
- #Blade
- #Version
- #QR
- #QR Code Generating
- #Array
- #Arrays with Key Values to String Statement
- #Short Tag
- #Activate
- #Real Time
- #Socket.io
- #301
- #Custom Directives
- #Iframe Detection
- #Date
- #Characters
- #Insert
- #Autoloader
- #Composer
- #Reading
There are no comments, make the firs comment