Styling Lists in CSS

CSSWeb DevelopmentFront End Technology

CSS allows us to style lists by specifying background, list-style properties, font styling, etc. The list-style property is a shorthand for specifying list-style-type, list-style-image, and list-style-position in the same order.

Syntax

The syntax of CSS list-style property is as follows −

Selector {
   list-style: /*value*/
}

Example

The following examples illustrate styling of lists −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
ul {
   display: flex;
   float: left;
   list-style-image: url("https://www.tutorialspoint.com/images/reactjs.png");
   background: lightseagreen;
   list-style-position: inside;
}
li {
   background: azure;
   margin: 5px 20px;
}
</style>
</head>
<body>
<h3>ReactJS</h3>
<ul>
<li>Lesson 1</li>
<li>Lesson 2</li>
<li>Lesson 3</li>
<li>Lesson 4</li>
<li>Lesson 5</li>
</ul>
</body>
</html>

Output

This gives the following output−

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
ol {
   width: 40%;
   color: white;
   list-style: lower-greek inside;
   background-image: url("https://www.tutorialspoint.com/ethereum/images/ethereum-mini-logo.jpg");
}
li {
   background-color: rgba(0,0,0,0.6);
   margin: 5px 30px;
}
</style>
</head>
<body>
<h2>Ethereum</h2>
<ol>
<li>Smart Contracts</li>
<li>Ganache</li>
<li>Creating Wallet </li>
<li>Deploying Contract</li>
</ol>
</body>
</html>

Output

This gives the following output −

raja
Published on 06-Jan-2020 14:26:00
Advertisements