CSS
🎯 CSS table-layout Property
The table-layout CSS property controls how column widths are calculated in an HTML table.
It defines the algorithm used by the browser to determine the layout of table columns.
🔹 Why Use table-layout?
This property is important for controlling performance and consistency in table rendering, especially in large datasets.
- Improves table rendering performance
- Prevents layout shifting
- Ensures consistent column widths
- Better control over table design
🧩 table-layout Values
1️⃣ auto (Default)
The browser calculates column widths based on the content inside each cell.
table {
table-layout: auto;
}
This may take slightly longer to render for large tables.
2️⃣ fixed
Column widths are determined by the first row and remain fixed regardless of content.
table {
table-layout: fixed;
}
This method is faster and provides a more stable layout.
3️⃣ initial
Resets the property to its default value (auto).
📌 Quick Summary
-
🧠 Overview
- auto → calculates column widths based on content (default)
- fixed → uses fixed column widths, improves performance
- initial → resets to default value
