By default, tables have "double" borders. The border-collapse property merges them into one.
table {
border: 2px solid black;
border-collapse: collapse;
}
Collapse: Merges borders.
Separate: Keeps default gaps.
BORDER-COLLAPSE: COLLAPSE
| ID | Name |
|---|---|
| 101 | Krishna J |
The width property controls how much horizontal space the table occupies.
table { width: 100%; }
Use percentages (%) for Responsive Design or pixels (px) for fixed sizes.
| Width: 50% |
|---|
| Width: 100% |
|---|
Adds "breathing room" inside each cell.
td { padding: 15px; }
Aligns content (left, center, right).
td { text-align: center; }
| Tight Padding | Spacious Padding |
Use background-color to make header cells (th) stand out from data cells (td).
th {
background-color: #38bdf8;
color: white;
}
| Course | Status |
|---|---|
| Java Full Stack | Enrolling |