CSS Lists: Several properties are available in CSS that are used to manage the lists. Lists are distributed as ordered and unordered kind of lists. The ordered lists provide the facility to mark the items of the list along with numbers and alphabet. An unordered list offers the facility to mark the items of lists using bullets.

With the help of CSS, we can style various lists. These lists give us the facility to:

  • Arrange the distance among the marker and the text inside the list.
  • Describe the image for any marker instead the use of any bullet point or any number.
  • Manage the appearance or pattern of any marker.
  • Position a marker inside or outside of a box that includes the items of a list.
  • Set the color of the background for lists and list items.

There are several properties of CSS which may be applied for styling the lists of CSS:

  • list-style-type: It is used to control the appearance or shape of a marker.
  • list-style-image: It is used to set the image to the marker instead of using any number or any bullet point.
  • list-style-position: This property describes the marker’s position, as its name implies.
  • list-style: This property is used as a shorthand property for all the properties mentioned above.
  • marker-offset: It describes the distance among the marker and the text. This property does not provide any support to Netscape 7 or IE6.

Take a look at the following illustration of list properties one by one:

CSS list-style-type

It permits us to modify the marker’s list type to some other type like Latin letters, roman numerals, circle, square, etc. The items of an ordered list are numbered in Arabic numerals (i.e., 1, 2, 3, etc.), although an unordered list’s items are remarked with the round bullet point.

When none value is set, it will erase all the bullets or markers.

Note: These lists also contain the default padding and margin. To erase, we have to add margin: 0 and padding: 0 to <ul> and <ol>.

Let’s have a look on the following example:

Example:                             

list-style-type

Output:

CSS Lists

CSS list-style-position

It is used to specify the appearance of a marker, whether it is outside or inside of a box. It also includes bullet points. This property contains two values.

inside: It specifies that bullet points are inside a list item. If any content goes to the next line, then content will wrap under a marker.

outside: It specifies that bullet points are outside a list item. These values used as the default value.

Let’s have a look on the following illustration:

Example:

Output:

CSS Lists

CSS list-style-image

The list-style-image property describes an image to the marker. It provides the facility to set the bullets of an image. It has a syntax that is similar to another property of CSS i.e., background-image. If it can’t find a corresponding image, it will automatically use the default bullets.

Example:

Output:        

CSS Lists

CSS list-style

It is used as a shorthand attribute that can be applied to set every list property within single expression. The values order of this attribute is image, position, and type. Although if an attribute value is not their then its default value is inserted.

Example:

Output:

CSS Lists

CSS lists along with colors

To show these lists more interesting and attractive, we can apply various colors to these lists. If we add something to the <ol> or <ul> tag, then it will affect a whole list, but if we add something to the <li> tag individually, then it will affect only the items corresponding list.

Example:

Output:

CSS Lists

Pin It on Pinterest

Share This