Are there alternative methods to align text in HTML tables using CSS in PHP?
To align text in HTML tables using CSS in PHP, you can use the "text-align" property in your CSS styles. This property allows you to align text within table cells to the desired position, such as left, center, or right.
<!DOCTYPE html>
<html>
<head>
<style>
table {
width: 100%;
}
th, td {
text-align: center;
padding: 8px;
}
</style>
</head>
<body>
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
<td>Row 1, Cell 3</td>
</tr>
<tr>
<td>Row 2, Cell 1</td>
<td>Row 2, Cell 2</td>
<td>Row 2, Cell 3</td>
</tr>
</table>
</body>
</html>
Keywords
Related Questions
- What are the considerations for managing multiple vendors in an eCommerce platform using PHP, especially in terms of order processing and communication?
- What methods can be used in PHP to ensure data validation and error checking at each step of a multi-page form submission process?
- Where can you learn the PHP basics to store images from $_FILES in a variable and then display them as images?