CSS1Home     Properties     Next     Prev

Chapter 3.6: CSS1 List Properties


TOP

List Properties

The list-style properties describe how list items (i.e. elements with a 'display' value of 'list-item') are formatted. The list-style properties can be set on any element, and it will inherit normally down the tree. However, they will only be have effect on elements with a 'display' value of 'list-item'. In HTML this is typically the case for the 'LI' element.


TOP

'list-style-type'

Value

disc | circle | square | decimal | lower-roman | upper-roman | lower-alpha | upper-alpha | none

disc : The marker is a filled circle

circle : The marker is a circle

square : The marker is a square

decimal : The marker is a number

lower-roman : The marker is lower-roman (i, ii, iii, iv, v, etc.)

upper-roman : The marker is upper-roman (I, II, III, IV, V, etc.)

lower-alpha : The marker is lower-alpha (a, b, c, d, e, etc.)

upper-alpha : The marker is upper-alpha (A, B, C, D, E, etc.)

none : No marker

Netscape 4.0, Internet Explorer 4.0

Notes in IE 4.0+:

  • This property works with ordered lists and unordered lists
  • This property does not work with definition lists
  • This property does not work with elements with "display" property set to "list-item"
  • Unordered lists have a default "list-style-type" value of "disc"
  • Ordered lists have a default "list-style-type" value of "decimal"

Notes in Netscape 4.0+:

  • This property works with ordered lists and unordered lists
  • This property does not work with definition lists
  • This property does not work with elements with "display" property set to "list-item"
  • Unordered lists have a default "list-style-type" value of "disc"
  • Ordered lists have a default "list-style-type" value of "decimal"
  • Only "decimal", "lower-roman", "upper-roman", "lower-alpha", and "upper-alpha" work on ordered lists
  • Only "none", "disc", "circle" and "square" work on unordered lists
Initial
disc
Applies to
elements with 'display' value 'list-item'
Inherited
yes
Percentage Values
N/A

The list-style-type sets the type of the list-item marker.

Note: Some browsers only support the "disc" value.

This property is used to determine the appearance of the list-item marker if 'list-style-image' is 'none' or if the image pointed to by the URL cannot be displayed.

OL { list-style-type: decimal } /* 1 2 3 4 5 etc. */
OL { list-style-type: lower-alpha } /* a b c d e etc. */
OL { list-style-type: lower-roman } /* i ii iii iv v etc. */

 

Example:

Source code:

<ul>
<li style="list-style-type: disc">list-style-type: disc</li>
<li style="list-style-type: circle">list-style-type: circle</li>
<li style="list-style-type: square">list-style-type: square</li>
<li style="list-style-type: decimal">list-style-type: decimal</li>
<li style="list-style-type: lower-roman">list-style-type: lower-roman</li>
<li style="list-style-type: upper-roman">list-style-type: upper-roman</li>
<li style="list-style-type: lower-alpha">list-style-type: lower-alpha</li>
<li style="list-style-type: upper-alpha">list-style-type: upper-alpha</li>
<li style="list-style-type: none">list-style-type: none</li>
<li>Back to normal Unorder List</li>
</ul>

Output:

  • list-style-type: disc
  • list-style-type: circle
  • list-style-type: square
  • list-style-type: decimal
  • list-style-type: lower-roman
  • list-style-type: upper-roman
  • list-style-type: lower-alpha
  • list-style-type: upper-alpha
  • list-style-type: none
  • Back to normal Unorder List

 

Example:

Source code:

<ol>
<li style="list-style-type: disc">list-style-type: disc</li>
<li style="list-style-type: circle">list-style-type: circle</li>
<li style="list-style-type: square">list-style-type: square</li>
<li style="list-style-type: decimal">list-style-type: decimal</li>
<li style="list-style-type: lower-roman">list-style-type: lower-roman</li>
<li style="list-style-type: upper-roman">list-style-type: upper-roman</li>
<li style="list-style-type: lower-alpha">list-style-type: lower-alpha</li>
<li style="list-style-type: upper-alpha">list-style-type: upper-alpha</li>
<li style="list-style-type: none">list-style-type: none</li>
<li>Back to normal Order List</li>
</ol>

Output:

  1. list-style-type: disc
  2. list-style-type: circle
  3. list-style-type: square
  4. list-style-type: decimal
  5. list-style-type: lower-roman
  6. list-style-type: upper-roman
  7. list-style-type: lower-alpha
  8. list-style-type: upper-alpha
  9. list-style-type: none
  10. Back to normal Order List

 


TOP

'list-style-image'

Value

<url> | none

url : the path to the image

none : No image will be displayed

Netscape 6.0, Internet Explorer 4.0

Notes in IE 4.0+:

  • This property works with ordered lists and unordered lists
  • This property does not work with definition lists
  • This property does not work with elements with "display" property set to "list-item"
Initial
none
Applies to
elements with 'display' value 'list-item'
Inherited
yes
Percentage Values
N/A

This property sets the image that will be used as the list-item marker. When the image is available it will replace the marker set with the 'list-style-type' marker.

UL { list-style-image: url(http://png.com/ellipse.png) }

 

Example:

Source code:

<ul>
<li style="list-style-type: disc">list-style-type: disc</li>
<li style="list-style-type: circle">list-style-type: circle</li>
<li style="list-style-type: square">list-style-type: square</li>
<li style="list-style-type: decimal">list-style-type: decimal</li>
<li style="list-style-type: lower-roman">list-style-type: lower-roman</li>
<li style="list-style-type: upper-roman">list-style-type: upper-roman</li>
<li style="list-style-type: lower-alpha">list-style-type: lower-alpha</li>
<li style="list-style-type: upper-alpha">list-style-type: upper-alpha</li>
<li style="list-style-type: none">list-style-type: none</li>
<li style="list-style-image: url(image/arrow.gif)">image/arrow.gif</li>
<li style="list-style-image: url(image/bgpans.gif)">image/bgpans.gif</li>
<li>Back to normal Unorder List</li>
</ul>

Output:

  • list-style-type: disc
  • list-style-type: circle
  • list-style-type: square
  • list-style-type: decimal
  • list-style-type: lower-roman
  • list-style-type: upper-roman
  • list-style-type: lower-alpha
  • list-style-type: upper-alpha
  • list-style-type: none
  • image/arrow.gif
  • image/bgpans.gif
  • Back to normal Unorder List

 

Example:

Source code:

<ol>
<li style="list-style-type: disc">list-style-type: disc</li>
<li style="list-style-type: circle">list-style-type: circle</li>
<li style="list-style-type: square">list-style-type: square</li>
<li style="list-style-type: decimal">list-style-type: decimal</li>
<li style="list-style-type: lower-roman">list-style-type: lower-roman</li>
<li style="list-style-type: upper-roman">list-style-type: upper-roman</li>
<li style="list-style-type: lower-alpha">list-style-type: lower-alpha</li>
<li style="list-style-type: upper-alpha">list-style-type: upper-alpha</li>
<li style="list-style-type: none">list-style-type: none</li>
<li style="list-style-image: url(image/arrow.gif)">image/arrow.gif</li>
<li style="list-style-image: url(image/bgpans.gif)">image/bgpans.gif</li>
<li>Back to normal Order List</li>
</ol>

Output:

  1. list-style-type: disc
  2. list-style-type: circle
  3. list-style-type: square
  4. list-style-type: decimal
  5. list-style-type: lower-roman
  6. list-style-type: upper-roman
  7. list-style-type: lower-alpha
  8. list-style-type: upper-alpha
  9. list-style-type: none
  10. image/arrow.gif
  11. image/bgpans.gif
  12. Back to normal Order List

 


TOP

'list-style-position'

Value

inside | outside

inside : Indents the marker and the text.

outside : Keeps the marker and the text to the left

Netscape 6.0, Internet Explorer 4.0

Notes in IE 4.0+:

  • This property works with ordered lists and unordered lists
  • This property does not work with definition lists
  • This property does not work with elements with "display" property set to "list-item"
Initial
outside
Applies to
elements with 'display' value 'list-item'
Inherited
yes
Percentage Values
N/A

The value of 'list-style-position' determines how the list-item marker is drawn with regard to the content.

ol { list-style-position: inside }

 

Example:

Source code:

<ul style="list-style-position: inside">
<li>Line with list-style-position: inside</li>
<li>Line with list-style-position: inside</li>
<li style="list-style-position: outside">Line with list-style-position: outside</li>
<li>Back to line with list-style-position: inside</li>
</ul>
<p>&nbsp;</p>
<ul style="list-style-position: outside">
<li>Line with list-style-position: outside</li>
<li>Line with list-style-position: outside</li>
<li style="list-style-position: inside">Line with list-style-position: inside</li>
<li>Back to line with list-style-position: outside</li>
<p>&nbsp;</p>

Output:

  • Line with list-style-position: inside
  • Line with list-style-position: inside
  • Line with list-style-position: outside
  • Back to line with list-style-position: inside

 

  • Line with list-style-position: outside
  • Line with list-style-position: outside
  • Line with list-style-position: inside
  • Back to line with list-style-position: outside
  •  

Example:

Source code:

<ol style="list-style-position: inside">
<li>Line with list-style-position: inside</li>
<li>Line with list-style-position: inside</li>
<li style="list-style-position: outside">Line with list-style-position:
outside</li>
<li>Back to line with list-style-position: inside</li>
</ol>
<p>&nbsp;</p>
<ol style="list-style-position: outside">
<li>Line with list-style-position: outside</li>
<li>Line with list-style-position: outside</li>
<li style="list-style-position: inside">Line with list-style-position:
inside</li>
<li>Back to line with list-style-position: outside</li>
</ol>
<p>&nbsp;</p>

Output:

  1. Line with list-style-position: inside
  2. Line with list-style-position: inside
  3. Line with list-style-position: outside
  4. Back to line with list-style-position: inside

 

  1. Line with list-style-position: outside
  2. Line with list-style-position: outside
  3. Line with list-style-position: inside
  4. Back to line with list-style-position: outside

 


TOP

'list-style'

Value

[disc | circle | square | decimal | lower-roman | upper-roman | lower-alpha | upper-alpha | none] || [inside | outside] || [<url> | none]

disc : The marker is a filled circle

circle : The marker is a circle

square : The marker is a square

decimal : The marker is a number

lower-roman : The marker is lower-roman (i, ii, iii, iv, v, etc.)

upper-roman : The marker is upper-roman (I, II, III, IV, V, etc.)

lower-alpha : The marker is lower-alpha (a, b, c, d, e, etc.)

upper-alpha : The marker is upper-alpha (A, B, C, D, E, etc.)

inside : Indents the marker and the text.

outside : Keeps the marker and the text to the left

url : the path to the image

none : No marker. No image will be displayed

Netscape 6.0, Internet Explorer 4.0

Notes in IE 4.0+:

  • This property works with ordered lists and unordered lists
  • This property does not work with definition lists
  • This property does not work with elements with "display" property set to "list-item"
  • Unordered lists have a default "list-style-type" value of "disc"
  • Ordered lists have a default "list-style-type" value of "decimal"
Initial
not defined for shorthand properties
Applies to
elements with 'display' value 'list-item'
Inherited
yes
Percentage Values
N/A

The 'list-style' property is a shorthand notation for setting the three properties 'list-style-type', 'list-style-image' and 'list-style-position' at the same place in the style sheet.

UL { list-style: upper-roman inside }
UL UL { list-style: circle outside }
LI.square { list-style: square }

Setting 'list-style' directly on 'LI' elements can have unexpected results. Consider:

<STYLE TYPE="text/css">
OL.alpha LI { list-style: lower-alpha }
UL LI { list-style: disc }
</STYLE>
<BODY>
<OL CLASS=alpha>
<LI>level 1
<UL>
<LI>level 2
</UL>
</OL>
</BODY>

Since the specificity (as defined in the cascading order) is higher for the first rule in the style sheet in the example above, it will override the second rule on all 'LI' elements and only 'lower-alpha' list styles will be used. It is therefore recommended to set 'list-style' only on the list type elements:

OL.alpha { list-style: lower-alpha }
UL { list-style: disc }

In the above example, inheritance will transfer the 'list-style' values from 'OL' and 'UL' elements to 'LI' elements.

A URL value can be combined with any other value:

UL { list-style: url(http://png.com/ellipse.png) disc }

In the example above, the 'disc' will be used when the image is unavailable.

Example:

Source code:

<style type="text/css">
  ol.alpha1 LI { list-style: lower-alpha }
  ul li { list-style: disc }
</style>
<ol class="alpha1">
  <li>level 1
  <ul>
    <li>level 2
  </ul>
</ol>
<p>&nbsp;</p>
<style type="text/css">
  ol.alpha2 { list-style: lower-alpha }
  ul { list-style: disc }
</style>
<ol class="alpha2">
  <li>level 1
  <ul>
    <li>level 2
  </ul>
</ol>
<p>&nbsp;</p>

Output:

  1. level 1
    • level 2

 

  1. level 1
    • level 2

 

Example:

Source code:

<ol style="list-style: inside url(image/arrow.gif)">
  <li>Line with list-style: inside url(image/arrow.gif)</li>
  <li>Line with list-style: inside url(image/arrow.gif)</li>
</ol>
<p>&nbsp;</p>
<ol style="list-style: outside url(no_image.gif)">
  <li>Line with list-style: outside url(no_image.gif)</li>
  <li>Line with list-style: outside url(no_image.gif)</li>
</ol>
<p>&nbsp;</p>

Output:

  1. Line with list-style: inside url(image/arrow.gif)
  2. Line with list-style: inside url(image/arrow.gif)

 

  1. Line with list-style: outside url(no_image.gif)
  2. Line with list-style: outside url(no_image.gif)

 


TOP     CSS1Home     Properties     Next     Prev

 

Hosted by www.Geocities.ws

1