Certainly! Below is the HTML code for a table where the first column lists the properties and each row contains property-value pairs. The table is set to display in right-to-left (RTL) direction.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>RTL Properties Table</title>
<style>
table {
border-collapse: collapse;
width: 50%;
direction: rtl; /* Set the table direction to right-to-left */
}
th, td {
border: 1px solid #000;
padding: 8px;
text-align: left; /* Align text to the left within each cell */
}
th {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<table>
<tr>
<th>Property</th>
<th>Value</th>
</tr>
<tr>
<td>Height</td>
<td>1.9m</td>
</tr>
<tr>
<td>Width</td>
<td>1.2m</td>
</tr>
<!-- Add more rows as needed -->
</table>
</body>
</html>
Explanation:
Customization:
-
Adding More Rows:
To add more property-value pairs, include additional <tr> (table row) elements between the <table> tags:
<tr>
<td>Depth</td>
<td>0.8m</td>
</tr>
-
Styling:
You can modify the style section to change the appearance of the table, such as adjusting widths, colors, fonts, etc.
Example with Additional Data:
Here's the table with more properties and values:
<table>
<tr>
<th>Property</th>
<th>Value</th>
</tr>
<tr>
<td>Height</td>
<td>1.9m</td>
</tr>
<tr>
<td>Width</td>
<td>1.2m</td>
</tr>
<tr>
<td>Depth</td>
<td>0.8m</td>
</tr>
<tr>
<td>Weight</td>
<td>15kg</td>
</tr>
</table>
Displaying the Table in RTL Language (e.g., Arabic or Hebrew):
If you're using a language that reads right-to-left, you can replace the text accordingly:
<table>
<tr>
<th>الخاصية</th>
<th>القيمة</th>
</tr>
<tr>
<td>الارتفاع</td>
<td>1.9م</td>
</tr>
<tr>
<td>العرض</td>
<td>1.2م</td>
</tr>
<!-- Add more rows as needed -->
</table>
Notes:
-
dir="rtl" Attribute:
You can also set the dir attribute to rtl directly on the table:
<table dir="rtl">
<!-- Table content -->
</table>
-
Text Alignment:
Even though the table direction is RTL, you might want the text inside the cells to align differently. Adjust text-align in the CSS as needed.
Complete Example in Context:
<!DOCTYPE html>
<html lang="ar">
<head>
<meta charset="UTF-8">
<title>جدول الخصائص</title>
<style>
table {
border-collapse: collapse;
width: 50%;
direction: rtl;
}
th, td {
border: 1px solid #000;
padding: 8px;
text-align: right;
}
th {
background-color: #e0e0e0;
}
</style>
</head>
<body>
<h2>جدول الخصائص والقيم</h2>
<table>
<tr>
<th>الخاصية</th>
<th>القيمة</th>
</tr>
<tr>
<td>الارتفاع</td>
<td>1.9م</td>
</tr>
<tr>
<td>العرض</td>
<td>1.2م</td>
</tr>
<tr>
<td>العمق</td>
<td>0.8م</td>
</tr>
<tr>
<td>الوزن</td>
<td>15كج</td>
</tr>
</table>
</body>
</html>
How to Use:
-
Copy the Code:
Copy the HTML code into a text editor and save the file with an .html extension.
-
View in Browser:
Open the HTML file in a web browser to see the table displayed in RTL format.
-
Adjust Content and Style:
Modify the properties, values, and styles as needed for your specific use case.
Let me know if you need further assistance or additional customization!