CSS - Basic CSS Part 3

May 28, 2026 3:00pm UTC (Check your timezone)

Theory Lab

Instructors: Jess, Carmen, and Eda

Basic CSS

Download iCal File

Before this session, please:

During this session, we’ll:

After this session, please:

Instructor notes

We can space list items using both margins and line-height.

For example, we can use margin-bottom for each list item:

1<link rel="stylesheet" href="styles.css">
2
3<ul>
4  <li>Item 1</li>
5  <li>Item 2</li>
6  <li>Item 3</li>
7</ul>

styles.css:

1li {
2  margin-bottom: 40px;
3}

With line-height, we can also adjust the vertical spacing between list items. It also affects the spacing between lines, if the list items contain multiple lines of text.

Note that it only applies a height to lines, not adjusting the spacing between items.

For example, to set the line height to be twice the size of the font size, we can do this:

1li {
2  line-height: 2;
3}

To customize how list items are displayed, we can use the list-style property. It’s a shorthand for three other properties:

With list-style-type, we can define the type of bullet point (for unordered lists) or number (for ordered lists).

The types of bullet points include discs, circles, squares, etc.

The types of numbers include decimal, Roman numerals, alphabetical characters, etc.

With list-style-position, we can adjust the position of the bullet point or number in relation to the list item’s content. The possible values are inside and outside. The default value is outside. It can be useful when there are multiple lines of text in a single list item and we want to control the alignment of the text.

With list-style-image, we can use an image as the bullet point. If the image is unavailable, the fallback will be square bullet points.

Default link styles are important for accessibility. Their purpose is to provide visual cues for users to distinguish them from other non-interactive elements.

For unvisited links, the default color is blue, and the text-decoration is set to underline. Visited links have the default color of purple. These make it easier for users to find links and keep track of the ones they’ve visited.

When we want to change these default styles, we should make sure that links are still distinct from other text and the colors use proper contrast with the background.

Links also have default hover and active states. We should also consider them when customizing styles for links!

The different states of links include:

These states have some default styles to make navigation more intuitive and improve the user experience.

They can be styled using pseudo-classes. Pseudo-classes allow us to style elements based on their state. They start with the colon (:) character, followed by the name.

For example, the unvisited link state can be styled with a:link:

1a:link {
2  color: darkblue;
3}

Similarly, other states can be styled as well:

 1a:visited {
 2  color: green;
 3}
 4
 5a:hover {
 6  color: green;
 7}
 8
 9a:focus {
10  outline: 2px solid orange;
11}
12
13a:active {
14  color: pink;
15}

Build a Stylized To-Do List

We’ll go through this exercise to practice what we’ve learned so far and style links based on their states!