Yogesh Chauhan's Blog

Styling Lists with CSS

in CSS on September 24, 2020

There are three different properties for styling list-items:

1. list-style-type (default: disc) 
2. list-style-image (default: outside) 
3. list-style-position (default: none) 

NOTE: above properties need to be declared in that order.

We can declare each property separately, or we can use list-style shorthand property.

list-style-type

list-style-type defines the shape/type of bullet point for each list-item.

We can add these values for list-style-type:

1. disc
2. circle
3. square
4. decimal
5. lower-roman
6. upper-roman
7. none

Example


li {
 list-style-type: square;
}

li {
 list-style-type: circle;
}

list-style-image

If we want to display an image instead of bullet point, we can use  list-style-image.

We can pass URL or local image as value.


li {
 list-style-image: url(images/image.png);
}

list-style-position

It defines where to position the list-item marker. We can add two values, either “inside” or “outside”.


li {
 list-style-position: outside;
}

Most Read

#1 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
PHP Variables ScopePHPRelative Length Units in CSSCSSWhat’s the difference between visibility: hidden and display: none?CSSShould we ever delete data from a database?MiscellaneousSorting Arrays in JavaScriptJavaScriptThe basics of @import rule in SCSS (Sass)SCSSLIKE and ILIKE Operators in PostgresPostgresfirst-of-type and last-of-type selectors in CSSCSSHow to define constants in PHP?PHPHow to modify navigation menus in WordPress?WordPressHow to set the permissions on all files and folders in Mac?MiscellaneousColleague UI Basics: The Context AreaColleague