Lists are a structure to oragnize data. HTML provides 2 basic kinds of lists: ordered (numbered) and unordered (bulleted). CSS provides some list-specific styles. Third-party libraries like Font Awesome can help make custom icons for bulleted lists.
Inspect the HTML of the list below.
The entire list is contained in an <ol>
element.
Each numbered item is contained in an <li>
element.
Inspect the HTML of the list below.
It continues the list above, so it has a start
attribute
to specify that it needs to begin at #6.
It also shows that you can nest other tags inside <li>
tags.
Use the dropdown below to change the CSS applied to the lists above.
The list-style-type
property affects the type of numbering
used for ordered lists. These are just a few examples of the possible
values. More can be explored
here.
.sample.interactive ol{
list-style-type:
;
}
Inspect the HTML of the list below.
The entire list is contained in an <ul>
element.
Each bulleted item is contained in an <li>
element.
Use the dropdown below to change the CSS applied to the list above.
The list-style-type
property affects the type of bullets
used for unordered lists.
.sample.interactive ul{
list-style-type:
;
}
The list below uses special styling from a third-party package called
Font Awesome to display specific icons instead of all the same standard icons.
Installing the Font Awesome library was as simple as downloading the files
and including a <link>
to the Font Awesome stylesheet
in the <head>
element. Using the icons was as simple
as adding the class names that you see when you inspect the HTML below.
Sometimes you need to outline a complex topic.
For example, the navigation for an entire web site may include
many levels of pages. That is a good time to use nested lists,
like the example below. Inspect the HTML and pay special attention
to <ul>
elements nested inside
<li>
elements to create submenus.
The list structure gives us plenty of elements to create a
drop-down navigation menu. If you
,
it will add class="navigation"
to the <nav>
tag,
which surrounds the outer <ul>
tag,
and you can inspect all the new styles that transform it into a dropdown menu
(or maybe you prefer to look directly at the CSS file).
You can
to remove the class and see the default styles again.
Using the examples above as a guide, create your own web page with some lists. Here are ideas and guidelines for your lists.