CSS Lists


🔹 What Are CSS Lists?

HTML lists like <ul>, <ol>, and <li> can be styled using CSS to change:

  • Bullet styles

  • List spacing

  • Positioning

  • Custom icons

  • List layout (horizontal/vertical)


🔸 1. Types of HTML Lists

  • Unordered List (<ul>) – Bulleted list

  • Ordered List (<ol>) – Numbered list

  • List Item (<li>) – List item inside ul/ol


🔸 2. Styling List Type

Use list-style-type to change bullets or numbering.

ul {
  list-style-type: square;
}

ol {
  list-style-type: upper-roman;
}

🔹 Common Values:

  • disc, circle, square, none (for <ul>)

  • decimal, lower-alpha, upper-roman, lower-greek (for <ol>)


🔸 3. Removing List Markers

ul {
  list-style-type: none;
}

This is often used in nav menus.


🔸 4. Changing List Position

ul {
  list-style-position: inside;
}

Values:

  • outside (default)

  • inside (bullets/number appear inside content box)


🔸 5. Custom List Icons with Images

ul {
  list-style-image: url('checkmark.png');
}

🔸 6. Horizontal Lists (Inline Navigation)

ul li {
  display: inline;
  margin-right: 20px;
}

Great for nav menus or toolbars.


🔸 7. Shorthand Property: list-style

ul {
  list-style: square inside;
}

Same as:

list-style-type: square;
list-style-position: inside;

Practice Questions

Q1. Change bullet style of a <ul> to circle.

Q2. Change number style of an <ol> to uppercase Roman.

Q3. Remove bullets from a list.

Q4. Set list markers inside the list content.

Q5. Apply a custom image as bullet.

Q6. Style list items to appear inline with spacing.

Q7. Combine list-style-type and list-style-position using shorthand.

Q8. Set a different bullet style for two <ul> lists.

Q9. Use lower-alpha for an ordered list.

Q10. Make a vertical navigation menu without bullets.


Go Back Top