混用 border-collapse: collapse 与单元格的 border-radius——合并边框模式下圆角可能不生效,需要 separate 模式配合 border-spacing: 0 实现圆角表格。
Chapter 4 · Section 4.3
Styling Lists and Tables
Lists (<ul>/<ol>) and tables (<table>) are two semantic tags that ship with default styles of their own. This section shows how to tame their default spacing, markers, and borders to produce clean, custom styles.
The list-style Family
Property
Common values
Description
list-style-type
disc / decimal / none
the shape of the marker; none is commonly used in navigation menus to remove the bullet
list-style-position
outside (default) / inside
inside lets the marker participate in text layout, indenting with the text on wrapped lines
list-style-image
url(...)
replaces the default marker with an image; now rarely used, usually replaced by ::marker or pseudo-elements
nav ul {
list-style: none;
margin: 0;
padding: 0; /* ul has a default padding-left that reserves room for bullets/numbers; clear it once the marker is removed */
}
Custom List Markers
The ::marker pseudo-element styles the list marker itself and is more flexible than replacing the whole list-style-image — you can set the marker's color and font size independently without affecting the list item text.
TipEvery table on this tutorial site (including this one) uses border-collapse: collapse — the single line that makes tables look "clean" instead of like a collection of independent boxes.
Zebra Striping and Responsive Tables
Using the :nth-child() structural pseudo-class to alternate row colors is the classic way to improve readability of wide tables (a full introduction to structural pseudo-classes is in 2.4 Pseudo-class Selectors):
Removing list-style but forgetting to clear the default padding-left, so the list still shows an unexplained indent.
Without table-layout: fixed, an overlong cell can stretch the whole column or even the entire table, breaking the intended layout.
Mixing border-collapse: collapse with border-radius on cells — in collapsed mode rounded corners may not apply; you need separate mode combined with border-spacing: 0 to get rounded tables.