Вы находитесь на странице: 1из 3

7/21/2014

HOME

CSS Styling Lists

HTML

CSS

JAVASCRIPT

SQL

PHP

JQUERY

XML

ASP.NET

MORE...

REFERENCES

EXAMPLES

FORUM

Search w3schools.com

CSS Tutorial
CSS HOME
CSS Introduction

Select Language

CSS Syntax
CSS Selectors
CSS How To
CSS Backgrounds

WEB HOSTING

CSS Lists

UK Reseller Host

cPanel Hosting

CSS Text
CSS Fonts
CSS Links
CSS Lists

Previous

Next Chapter

The CSS list properties allow you to:

CSS Tables

Set different list item markers for ordered lists


Set different list item markers for unordered lists
Set an image as the list item marker

CSS Box Model


CSS Border
CSS Outline
CSS Margin
CSS Padding
CSS Dimension

In HTML, there are two types of lists:

CSS Positioning
CSS Floating
CSS Align

FREE Website BUIL

Free HTML5 Templ

W3SCHOOLS EXA

HTML, C SS, JavaSc


PHP, jQuery, XML,
ASP C ertification

List

CSS Display

WEB BUILDING

XML Editor - Free T

unordered lists - the list items are marked with bullets


ordered lists - the list items are marked with numbers or letters

SHARE THIS PA

With CSS, lists can be styled further, and images can be used as the list item marker.

CSS Combinators
CSS Pseudo-class
CSS Pseudo-element
CSS Navigation Bar

Different List Item Markers


The type of list item marker is specified with the list-style-type property:

CSS Image Gallery


CSS Image Opacity
CSS Image Sprites
CSS Media Types
CSS Attr Selectors

CSS3 Tutorial
CSS3 Introduction
CSS3 Borders
CSS3 Backgrounds
CSS3 Gradients
CSS3 Text Effects

Example
ul.a {
list-style-type: circle;
}
ul.b {
list-style-type: square;
}
ol.c {
list-style-type: upper-roman;
}

CSS3 Fonts
CSS3 2D Transforms
CSS3 3D Transforms
CSS3 Transitions
CSS3 Animations
CSS3 Multiple Columns

ol.d {
list-style-type: lower-alpha;
}
Try it yourself

CSS3 User Interface


CSS Summary

Some of the values are for unordered lists, and some for ordered lists.

CSS Examples

An Image as The List Item Marker

CSS Examples
CSS Quiz

To specify an image as the list item marker, use the list-style-image property:

CSS Certificate

CSS References
CSS Reference
CSS Selectors
CSS Reference Aural
CSS Web Safe Fonts
CSS Units

Example
ul {
list-style-image: url('sqpurple.gif');
}

WEB RESOURC

Web Statistics

Web Validation

Try it yourself

CSS Colors
CSS Color Names

The example above does not display equally in all browsers. IE and Opera will display the image-marker a little bit higher
than Firefox, Chrome, and Safari.

CSS Color HEX

If you want the image-marker to be placed equally in all browsers, a crossbrowser solution is explained below.

CSS Color Values

Crossbrowser Solution
The following example displays the image-marker equally in all browsers:

Example
http://www.w3schools.com/css/css_list.asp

1/3

7/21/2014

CSS Styling Lists


ul {
list-style-type: none;
padding: 0px;
margin: 0px;
}
ul li {
background-image: url(sqpurple.gif);
background-repeat: no-repeat;
background-position: 0px 5px;
padding-left: 14px;
}
Try it yourself

Example explained:
For ul:
Set the list-style-type to none to remove the list item marker
Set both padding and margin to 0px (for cross-browser compatibility)
For all li in ul:
Set the URL of the image, and show it only once (no-repeat)
Position the image where you want it (left 0px and down 5px)
Position the text in the list with padding-left

List - Shorthand property


It is also possible to specify all the list properties in one, single property. This is called a shorthand property.
The shorthand property used for lists, is the list-style property:

Example
ul {
list-style: square url("sqpurple.gif");
}
Try it yourself

When using the shorthand property, the order of the values are:
list-style-type
list-style-position (for a description, see the CSS properties table below)
list-style-image
It does not matter if one of the values above are missing, as long as the rest are in the specified order.

More Examples
All the different list-item markers for lists
This example demonstrates all the different list-item markers in CSS.

All CSS List Properties


Property

Description

list-style

Sets all the properties for a list in one declaration

list-style-image

Specifies an image as the list-item marker

list-style-position

Specifies if the list-item markers should appear inside or outside the content flow

list-style-type

Specifies the type of list-item marker

Previous

http://www.w3schools.com/css/css_list.asp

Next Chapter

2/3

7/21/2014

CSS Styling Lists

Top 10 Tutorials

Top 10 References

Top 10 Examples

Web Certificates

HTML Tutorial
HTML5 Tutorial
C SS Tutorial
C SS3 Tutorial
JavaScript Tutorial
jQuery Tutorial
SQL Tutorial
PHP Tutorial
ASP.NET Tutorial
XML Tutorial

HTML/HTML5 Reference
C SS 1,2,3 Reference
C SS 3 Browser Support
JavaScript
HTML DOM
XML DOM
PHP Reference
jQuery Reference
ASP.NET Reference
HTML C olors

HTML Examples
C SS Examples
JavaScript Examples
HTML DOM Examples
PHP Examples
jQuery Examples
XML Examples
XML DOM Examples
ASP Examples
SVG Examples

R EPO R T ER R O R

HO ME |

TO P

Color Picker

HTML C ertificate
HTML5 C ertificate
C SS C ertificate
JavaScript C ertificate
jQuery C ertificate
PHP C ertificate
XML C ertificate
ASP C ertificate

PR INT

FO R UM

ABO UT

ADVER TISE W ITH US

W3Schools is optimized for learning, testing, and training. Examples might be simplified to improve reading and basic understanding. Tutorials, references, and examples
are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use,
cookie and privacy policy. C opyright 1999-2014 by Refsnes Data. All Rights Reserved.

http://www.w3schools.com/css/css_list.asp

3/3

Вам также может понравиться