Easy Tutorial
❮ Css Rwd Viewport Css Image Gallery ❯

CSS Lists


CSS list properties are used to:


Lists

In HTML, there are two types of lists:

Using CSS, you can further style lists and use images as list item markers.

Unordered List Example:

Ordered List Example:


Different List Item Markers

The list-style-type property specifies the type of list item marker:

Example

ul.a { list-style-type: circle; }
ul.b { list-style-type: square; }

ol.c { list-style-type: upper-roman; }
ol.d { list-style-type: lower-alpha; }

Some values are for unordered lists, and some are for ordered lists.


Image as List Item Marker

To specify an image as the list item marker, use the list-style-image property:

Example

ul {
    list-style-image: url('sqpurple.gif');
}

The above example may display differently across browsers. IE and Opera may show the image marker slightly higher than Firefox, Chrome, and Safari.

If you want the same image marker in all browsers, you should use a browser compatibility solution, as follows:

Browser Compatibility Solution

The following example will display the image marker consistently across all browsers:

Example

ul {
    list-style-type: none;
    padding: 0px;
    margin: 0px;
}
ul li {
    background-image: url(sqpurple.gif);
    background-repeat: no-repeat;
    background-position: 0px 5px;
    padding-left: 14px;
}

Example explanation:


List - Shorthand Property

You can specify all the list properties in one single property. This is called a shorthand property.

To use the shorthand property for lists, set the list style properties as follows:

Example

ul {
    list-style: square url("sqpurple.gif");
}

You can set the following properties in order:

If one of the values is missing, the rest will still be specified in the given order.


More Examples

All Different List Item Markers


Removing Default Settings

The list-style-type: none property can be used to remove the markers. By default, <ul> or <ol> also have padding and margin set, which can be removed using margin: 0 and padding: 0:

Example

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

All CSS List Properties

Property Description
list-style A shorthand property for setting all list properties in one declaration
list-style-image Sets an image as the list item marker
list-style-position Sets the position of the list item markers
list-style-type Sets the type of list item marker
❮ Css Rwd Viewport Css Image Gallery ❯