List

CSS lists are one of the most versatile elements of web design. Aside from being used for making, well, lists, they are also used for navigation, layouts, slideshows, carousels, and so on.

Let's see some of their properties.

list-style

The list-style CSS property is shorthand for the list-style-type, list-style-image, and list-style-position properties. These properties are actually the values that the list-style CSS property supports. We'll see all these properties next.

Description

The list-style property supports one, two, or three values, in any order. If a value isn't declared, it will use its default value.

CSS:

/*Default values*/
ul { list-style: disc outside none; }
/*One value, the other two are default*/
ul { list-style: circle; }
/*Two values, the other one is defaults*/
ul { list-style: lower-roman inside; }
/*Three values*/
ul { list-style: decimal outside url(../images/list-bullet.png); }

list-style-type

The list-style-type CSS property defines the type of graphic or marker (also called bullet) the list will use. The color of the marker is determined by the color of the text of the element it's applied to.

Description

The list-style-type property supports many values, but we'll list 15 of the most commonly used ones: armenian, circle, decimal, decimal-leading-zero, disc, georgian, lower-alpha, lower-greek, lower-latin, lower-roman, none, square, upper-alpha, upper-latin, and upper-roman.

Here's a screenshot with all values except the none value:

Description

CSS:

/*Style: 01, 02, 03...*/
ul { list-style-type: decimal-leading-zero; }
/*Style: α, β, γ...*/
ul { list-style-type: lower-greek; }
/*Style: A, B, C...*/
ul { list-style-type: upper-latin; }

list-style-position

The list-style-position CSS property defines the location of the marker.

Description

The list-style-position property supports two keyword values: inside and outside.

inside

When the inside value is applied, the marker will appear inside the text. If there's a line that wraps, the marker will be flushed to the left and not "sticking out" like in traditional lists.

outside

The default value is outside. When this value is applied (or not, since it's the default), the marker will appear outside the text. If there's a line that wraps, the marker will be outside the text block. It will "stick out" just like in traditional lists.

CSS:

ul {
  list-style-position: inside;
}

list-style-image

The list-style-image CSS property allows us to replace the default markers with a custom image.

Description

The list-style-image property supports one keyword value and one function: none and url().

  • none: No image is used to replace the marker
  • url(): It's used to define the path to the image that will replace the marker

CSS:

ul {
  list-style-image: url(../images/list-bullet.png);
}

Here's a demo in CodePen with all HTML lists: http://tiny.cc/html-lists

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.121.8