CSS

CSS Lists || Bcis Notes

CSS Lists

Two types of list exist in CSS i.e. Unordered lists and Ordered Lists

UNORDERED LISTS:
In unordered lists, the list items are marked with bullets.

ORDERED LISTS:
In ordered lists, the list items are marked with numbers and alphabet.

 

The CSS list properties allow you to:

  • Set different list item markers for ordered lists
  • Set different list item markers for unordered lists
  • Set an image as the list item marker
  • Add background colors to lists and list items

List Item Marker: This property specifies the type of item marker i.e. unordered list or ordered

                             Syntax:     list-style-type:value;

Different List Item Markers
The value can be the following:

  • circle
  • decimal , eg :1,2,3,etc
  • decimal-leading-zeroes , eg :01,02,03,04,etc
  • lower-roman
  • upper-roman
  • lower-alpha, eg : a,b,c,etc
  • upper-alpha, eg : A,B,C,etc
  • square

The following example shows some of the available list item markers:

CODE:

 

Results:

 

An Image as The List Item Marker
The list-style-image property specifies an image as the list item marker:

CODE:

 

Results:

 

Position The List Item Markers
The list-style-position property specifies the position of the list-item markers (bullet points).

list-style-position: outside;” means that the bullet points will be outside the list item. The start of each line of a list item will be aligned vertically.

list-style-position: inside;” means that the bullet points will be inside the list item. As it is part of the list item, it will be part of the text and push the text at the start.

CODE:

 

Result:

 

List – Shorthand property
The list-style property is a shorthand property. It is used to set all the list properties in one declaration:

CODE:

 

Results:

When using the shorthand property, the order of the property values are:

  • list-style-type (if a list-style-image is specified, the value of this property will be displayed if the image for some reason cannot be displayed)
  • list-style-position (specifies whether the list-item markers should appear inside or outside the content flow)
  • list-style-image (specifies an image as the list item marker)

 

Styling List With Colors
We can also style lists with colors, to make them look a little more interesting.

Anything added to the <ol> or <ul> tag, affects the entire list, while properties added to the <li> tag will affect the individual list items:

CODE:

 

Results:

 

All CSS List Properties

 

You may also like: CSS Text

One thought on “CSS Lists || Bcis Notes

  1. I just wanted to post a word to be able to appreciate you for these pleasant hints you are sharing at this website. My rather long internet search has at the end been honored with sensible facts and techniques to talk about with my neighbours. I would repeat that most of us website visitors are rather endowed to live in a superb community with so many brilliant people with beneficial plans. I feel pretty happy to have used your webpages and look forward to really more exciting times reading here. Thanks a lot again for all the details. Lyssa Lyon Volkan

Leave a Reply

Your email address will not be published. Required fields are marked *