Ordered List
Example: List of fruits
- Banana
- Orange
- Apple
Un-ordered List:
- BananaÂ
- Orange
- Apple
How to style the un ordered list with CSS?
Example 1:
File 1 : Â stylefile.css
ul.first { Â Â Â list-style-type: square; } |
File 2: index.html
<head>
<style> <link rel=”Stylesheet” type=”text/css” href=”stylefile.css” /> </head> <p>This is unordered lists</p> |
Output:
This is unordered list
- BananaÂ
- Orange
- Apple
How to style the ordered list with CSS?
Example 2:
File 1 : Â stylefile.css
ol.first { Â Â Â list-style-type:upper-roman; } |
File 2: index.html
<head> <style> <link rel=”Stylesheet” type=”text/css” href=”stylefile.css” /> </head> <p>This is ordered list with upper roman style</p> |
Output:
This is ordered list with upper roman style
- BananaÂ
- Orange
- Apple
Some explanations:
CSSÂ |
How it works |
ol { background: red; padding: 20px; } |
It will set the background color as red and set padding to 20px for ordered list |
ul { background:red; padding: 66px; } |
 It will set the background color as red and padding to 20px for un-ordered list. |
 ul li { background:red; margin: 44px; } |
 it will apply the css on all list of un-ordered lists. |
 ol li { background:red; margin: 33px; } |
 It will apply the css on all lists of ordered lists. |
ol.t4tutorials{ background:red; margin: 33px; } |
 It will apply the CSS on ordered list that have class t4tutorials. |