CSS ListsIn this tutorial you will learn how to format HTML lists using CSS. Show HTML Lists❮ Previous Next ❯ HTML lists allow web developers to group a set of related items in lists.
Example
An unordered HTML list:
An ordered HTML list:
Styling lists
Lists behave like any other text for the most part, but there are some CSS properties specific to lists that you need to know about, as well as some best practices to consider. This article explains all.
<ul>: The Unordered List elementThe <ul> HTML element represents an unordered list of items, typically rendered as a bulleted list.
How to Make Lists in HTMLIn HTML, we can list items either in an ordered or unordered fashion. An ordered list uses numbers or some sort of notation that indicates a series of items. For example, an ordered list can start with number 1, and continue through 2, 3, 4, and so on. Your ordered list can also start with the letter A and go through B, C, D, and so on. Here is an example of an ordered list with students' names and marks. On the other hand, we have unordered lists, like a TODO list for example. Here I am so passionate about coding that I skipped my breakfast 🤓. There is one more type of list called a description list that we will learn as well below. Now let's get into a bit more detail and see how to create each type of list in HTML. HTML Unordered List | HTML Bulleted ListHTML Unordered List or Bulleted List displays elements in bulleted format . We can use unordered list where we do not need to display items in any particular order. The HTML ul tag is used for the unordered list. There can be 4 types of bulleted list:
To represent different ordered lists, there are 4 types of attributes in <ul> tag.
How To Format Bullet Lists (<ul>) Using CSSBullet lists in HTML come in two varieties: Ordered Lists (in which each line begins with a number or letter) and Unordered Lists (in which each line begins with the same bullet shape or image).
On this page we will discuss how to format unordered lists so they have a bit more style. We'll also show you how to use an image for bullet lists. CSS StylesThere are several ways to format the style of your lists but they all use the same basic set of instructions. These are CSS (Cascading Style Sheet) instructions and they look like this: font-family: Verdana, Arial, Helvetica, sans-serif; These are just a small sample of the styles which are available. The ones above are common CSS styles and can be used anywhere there is text. There are also styles specific to lists, such as: list-style-position: outside; When formatting a list, you can choose as many of these styles as you like. If you only need to use an image for the bullets, then that's the only style you choose. For this page we will use the following requirements to illustrate the methods:
More formatting options will follow later. Method 1: Universal StyleThe simplest way to format your lists is to define a style which applies to all lists in the page. In the head of your web page, add the following code: <style type="text/css"> Syntax: list-style-type: <value> Syntax: list-style-image: <value> Syntax: list-style-position: <value> Example
The example on the right is the result of the style below. Note that both a list-style-type and list-style-type are defined - the arrow image is used unless it cannot be found or the user has image display disabled, in which case the list uses square bullets. <style type="text/css"> |