XML technologies / CSS / CSS Cookbook / Lists / Displaying the list marker inside the item

(Excerpt from “CSS Kochbuch” by Christopher Schmitt)

Problem

The marker should appear inside the list item’s box, as shown in the following figure, so the text flows around it.

Displaying the marker inside the list item

Figure: Displaying the marker inside the list item.

Solution

Use the property list-style-position with the value inside:

li {
 list-style-position: inside;
 width: 33%;
 padding: 0;
 margin: 0;
}
ul {
 margin: 0;
 padding: 0 0 0 1em;
}

Discussion

List markers normally appear outside the items, producing the typical list layout. Some designs may instead call for the marker to appear with the text, for example to avoid excessive empty space on the left. You can enhance this recipe visually by using your own marker, as in the next figure, where arrows replace the default marker.

A custom marker inside the list item

Figure: A custom marker inside the list item.

See also

The CSS 2.1 specification for the property list-style-position.

  

 

 

 

back to top