Published by Patrick Mutisya · 14 days ago
By the end of this lesson students will be able to apply CSS styles to any element on a web page, including ordered and unordered lists.
style attribute.<style> block in the document’s <head>..css file and linked with <link rel="stylesheet">. (The file itself is not shown here.)A CSS rule consists of a selector followed by a declaration block:
selector {property: value;
property: value;
}
Example – making all paragraphs red:
p {color: red;
}
<ol>)Common properties for ordered lists:
| Property | Possible values | Effect |
|---|---|---|
list-style-type | decimal, lower-alpha, upper-roman, … | Changes the marker style. |
list-style-position | inside, outside | Places the marker inside or outside the list item box. |
margin-left | any length value | Indents the whole list. |
Example – a Roman‑numeral ordered list with inside markers:
ol.custom {list-style-type: upper-roman;
list-style-position: inside;
margin-left: 2em;
}
HTML markup:
<ol class="custom"><li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
<ul>)Key properties for unordered lists:
| Property | Possible values | Effect |
|---|---|---|
list-style-type | disc, circle, square, none | Changes the bullet shape. |
list-style-image | url('image.png') | Uses a custom image as the bullet. |
list-style-position | inside, outside | Controls where the bullet appears relative to the text. |
Example – a square‑bullet list with outside markers:
ul.square {list-style-type: square;
list-style-position: outside;
margin-left: 1.5em;
}
HTML markup:
<ul class="square"><li>Apple</li>
<li>Banana</li>
<li>Cherry</li>
</ul>
Lists can inherit or override styles from parent elements. For example, to colour all list items blue while keeping the list markers black:
ul.coloured li {color: blue; /* text colour */
}
ul.coloured {
color: black; /* marker colour */
}
list-styles.html..roman for ordered lists using upper‑roman markers..bullet for unordered lists using circle markers.list-style-position to inside and observe the effect.selector { property: value; }.list-style-type to change marker shapes or numbering systems.list-style-image for custom bullet graphics.list-style-position.