Javatpoint Logo
Javatpoint Logo

CSS List Styles

The List in CSS determines how the contents or items are listed in a certain fashion, i.e., they can be arranged either neatly or randomly, which aids in creating a clean webpage. Because they are adaptable and simple to handle, they may be used to organize large amounts of material. The list's default style is borderless. The list may be divided into two categories:

  1. Unordered List: By default, the list elements in unordered lists are denoted with bullets, which are tiny black circles.
  2. Ordered List: The list elements in ordered lists are identified by numbers and letters.

The following CSS list properties are available for usage in controlling the CSS lists:

  • List-style-type:This property is used to determine the look of the list item marker, such as a disc, character, or custom counter style.
  • List-style-image: The pictures that will serve as list item markers may be specified using this parameter.
  • List-style-position: It describes where the marker box should be about the main block box.
  • List-style: The list style is configured with this attribute.

We shall now learn more about these characteristics through examples.

List-style-type property

The default list type of marker may be changed to a variety of other types, including square, circle, Roman numerals, Latin letters, and many more. The entries in an unordered list are denoted by round bullets (•), while the items in an ordered list are numbered by default using Arabic numerals (1, 2, 3, etc.).

The markings or bullets will be removed if we set their value to none.

Syntax:

list-style-type:value;

We may use the value as follows:

  1. circle
  2. decimal, e.g.:1,2,3, etc
  3. decimal-leading-zeroes , eg :01,02,03,04,etc
  4. lower-roman
  5. upper-roman
  6. lower-alpha, e.g., a,b,c, etc
  7. upper-alpha, e.g., A, B, C, etc
  8. square

Note: The default padding and margin are also included in the list. It is necessary to add padding:0 and margin:0 to the <ol> and <ul> tags to eliminate this.

Example

This example shows a CSS List with several list-style types and values set to square and upper-alpha and many.

Output

CSS List Styles

List-style-position property

It indicates whether the marker appears within or outside of the box holding the bullet points. It has two values in it.

  • Inside: This indicates that the list item will contain the bullet points. If the text in this extends to the second line, it will wrap beneath the marker.
  • Outside: It indicates that the list item's bullet points will be outside of it. It is a default value.

Output

CSS List Styles

List Styling

The list may be styled using CSS. The lists can have custom backgrounds, padding, borders, and colors.

The different stylistic properties are applied to the element in the CSS List described in this example.

Output

CSS List Styles

Lists styled with colour

We may decorate lists with colors to make them more visually appealing and engaging. Anything added to the <ul> or <ol> tags will affect the whole list. However, anything added to a specific <li> tag will only affect that list's items.

Output

CSS List Styles





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA