At the end of this Lesson you will be able to:
You can view a finished version of this project by clicking the image below.
Lists of bulleted items are commonly used in web pages to make text easier-to-read and instructions easier-to-follow.
You can create two types of lists in HTML:
In HTML, you can think of any list as containing two parts: the list as a whole, and the individual items in the list.
<ul>
<li>Pellentesque non dignissim tellus</li>
<li>Ut convallis euismod quam non luctus</li>
</ul>
An ordered list begins and ends as follows. The ‘ol’ stands for ordered list.
<ol>
<li>Pellentesque non dignissim tellus</li>
<li>Ut convallis euismod quam non luctus</li>
</ol>
<li>Pellentesque non dignissim tellus</li>
<li>Ut convallis euismod quam non luctus</li>
In this Lesson you will work with these two files:
First, let’s edit the HTML file from your previous Lesson:
<title>Responsive web page with unordered and ordered lists</title>
<meta name="description" content="A sample responsive web page with examples of unordered and ordered lists.">
<link rel="stylesheet" href="base-4.css">
You are now ready to work with your new web page (base-4.html) and stylesheet (base-4.css).
In your base-4.html file, add the following new content at the bottom of the web page, just before the closing </body> tag.
<ul>
<li>Pellentesque non dignissim tellus.</li>
<li>tincidunt imperdiet sapien</li>
<li>Nunc rhoncus, massa in scelerisque lacinia</li>
</ul>
<ol>
<li>Integer et fringilla dolor.</li>
<li>Maecenas eu scelerisque mauris</li>
<li>Duis velit turpis, faucibus id</li>
</ol>
As with other elements of a web page, such as headings and text paragraphs, web browsers apply default styles to unordered and ordered lists.
However, because you have reset all default styles at the beginning of your stylesheet, you will need to add styles of your own for lists to display correctly.
In your base-4.css file, add the following new CSS styles at the bottom of the stylesheet, after the paragraph text styles.
/* ==== BULLETS ==== */
ul li, ol li {
font-family: sans-serif;
font-weight: normal;
font-size: calc(15px + (18 - 15) * ((100vw - 320px)/(1600 - 320)));
}
/* Mobiles */
@media all and (max-width:767px) {
ul, ol { margin-left: 5% }
ul li, ol li {
line-height: 1.5;
margin-bottom: 5%;
}
}
/* Desktop */
@media all and (min-width:768px) {
ul, ol { margin-left: 2% }
ul li, ol li {
line-height: 1.6;
margin-bottom: 2%;
}
}
Save your HTML and CSS files.
Reload your base-4.html file in your web browser. It should now look as shown below.
Before you validate your web page and upload it to GitHub, ensure the following details are correct within the <head> of your base-4.html file.
To check the HTML in your web page is correct or valid, use the official W3C Markup Validation Service as follows.
To check your CSS is correct, use the official W3C CSS Validation Service. Follow these steps.
After validating your web page and stylesheet, you are now ready to upload them to your account on GitHub.
Your web page is now published on GitHub at a web address similar to the following, where username is the username you have chosen for your GitHub account:
https://username.github.io/base-4.html
It may take a few minutes for your uploaded files to appear on GitHub.
HTML lists
From W3 Schools
CSS lists
From Geeks for Geeks
CSS bullet style explained
by Nesha Zoric on dev.to
Bullet point lists
From the Free Tutorial Center
Video: Styling unordered lists
From Jamie McGibbon at Technical Cafe
Return to Contents.