CSS
CSS introduction
Stylesheets
CSS syntax
Classes and ID's
CSS Comments
BG properties
Text properties
Font properties
List properties
Border properties
Margin properties
Padding properties
Outline properties
Table properties
Dim properties
Class properties
Position properties
Pseudo classes
Pseudo elements
Media types
Summary

Programming

Programming intro
Java

Markup

First webpage guide
HTML
XHTML

Browser scripting

Javascript
VBScript
AJAX

Server scripting

PHP
ASP

Making money online

Make money online

CSS list properties

With CSS list properties, you can specify how lists appear.

This lesson focuses on:

Setting the marker for a list

The marker for a list is set with the list-style-type attribute.

Possible values for the list-style-type attribute:

Example:

<html>
<head>
<title>Lists</title>
</head>
<body>
<ul style="list-style-type: square;">
<li>green</li>
<li>blue</li>
<li>gray</li>
<li>orange</li>
</ul>

<ul style="list-style-type: upper-alpha;">
<li>green</li>
<li>blue</li>
<li>gray</li>
<li>orange</li>
</ul>

<ol style="list-style-type: disc;">
<li>green</li>
<li>blue</li>
<li>gray</li>
<li>orange</li>
</ol>

<ol style="list-style-type: circle;">
<li>green</li>
<li>blue</li>
<li>gray</li>
<li>orange</li>
</ol>
</body>
</html>

Output:

  • green
  • blue
  • gray
  • orange
  • green
  • blue
  • gray
  • orange
  1. green
  2. blue
  3. gray
  4. orange
  1. green
  2. blue
  3. gray
  4. orange

In the above example, there are four lists. The marker for the first list is set to square. The marker for the second list is set to upper-alpha. The marker for the third list is set to disc. The marker for the fourth list is set to circle.

Specifying where a list is placed

The location of a list is specified with the list-style-position attribute. The location of a list can be specified as its default location using the value "inside" or as another location so that it can be displayed as an indented list using the value "outside".

Example:

<html>
<head>
<title>Lists</title>
</head>
<body>
<ul style="list-style-position: outside;">
<li>green</li>
<li>blue</li>
<li>gray</li>
<li>orange</li>
</ul>

<ol style="list-style-position: inside;">
<li>green</li>
<li>blue</li>
<li>gray</li>
<li>orange</li>
</ol>
</body>
</html>

Output:

  • green
  • blue
  • gray
  • orange
  1. green
  2. blue
  3. gray
  4. orange

In the above example, there are two lists. The position of the first list is set to outside which is the default positioning of the list. The position of the second list is set to inside which makes the list indented.

Practice

Online code editor
Practical examples
Practical exercises
Step-by-step tutorials

Reference

Terms glossary
Reference material

Rate this site

Rate this site
Visitor comments