XML technologies / CSS / CSS Cookbook / Lists / Cross-browser indentation
(Excerpt from “CSS Kochbuch” by Christopher Schmitt)
Problem
Browsers use different methods to indent lists. Left margins should provide a consistent appearance in all CSS-capable browsers.
Solution
Set the element ul to use values for the properties margin-left and padding-left:
ul {
margin-left: 40px;
padding-left: 0px;
}Discussion
Browsers use different methods to indent a list. Mozilla and Netscape 6+ control indentation using the property padding (padding). Internet Explorer and Opera instead use margin (margin).
For a consistent appearance across browsers, explicitly set values for both properties. Define the indentation itself using only one of them. Splitting indentation between both properties causes inconsistent rendering across browsers.
If you set both properties to zero for a list directly descended from the element body, the browser may display list markers outside the visible area. To ensure that users see them, set either left padding or left margin for elements ul to at least 1em.
See also
The recipe Defining hanging indents for lists for creating hanging indents,
the CSS 2.1 specification for the property
margin.
Copyright of the German edition © 2007 by O’Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “CSS Kochbuch” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstr. 81, 50670 Köln