You use lists for multiple reasons on a website. In this guide we'll cover how to create lists and common use cases on websites.
A list in its most basic structure has two types of tags: a wrapper (the list itself) and the individual items (list items).
A list item looks like this
The wrapper can either be categorized as an unordered list or an ordered list. If the list items can be rearranged and the meaning and purpose still preserved than use an unordered list. Otherwise use an ordered list. For instance you can't be rearranging a step-by-step guide so you should use the ordered list tag.
There are multiple reasons for using a list on a website. Let's explore different implementations so that you can feel more equipped when using these tags.
Nav menus are essential for organizing content logically for users, improve SEO with proper hierarchy, offers better UX, and increases accessibility for screen readers and keyboard navigation.
Since the order doesn't impact the meaning we can go ahead and us an unordered list
You'll notice a couple of new tags being used. For a nav menu you can use the <nav></nav> tags to add semantic meaning to your website. This lets search crawlers have a better idea of getting around your website.
Nav menus are essentially a list of links and so you'll need to use the <a></a> tags to make your list items clickable and take website visitors where they want to go. To link to a specific page be sure to use the href attribute as in the example.
One of the quickest ways to convey the benefit of your product or service is with a feature or service list. You'll often seen these on the Home page or a Services page. Let's use my website as an example.
I am using a new tags called the <section></section> tags again which add some semantic meaning indicating a group of related content and the <h2></h2> which is a second heading to indicate a title of lower significance than the first heading <h1></h1> which is typically reserved for the main title for the page.
Your customers/clients are bound to have questions which is a where a Frequently Asked Questions section can come in handy. FAQs will have a question answer format. You can use two lists to accomplish this format: an outer list for the question and an inner list for the answer.
In addition to the nested lists for clear structure, you'll also notice the <section></section> tags again which add some semantic meaning indicating a group of related content. You'll also see I have used the <strong></strong> to convey extra importance to the question in my FAQ section. If I just used the <b></b> for bold it would add any additional semantic meaning besides darkening the text.
Whenever you are providing step-by-step instructions such as a recipe, tutorial, etc. you'll want to use the list tags.
Here I am using a new tag pair the <code></code> tags to wrap around text that is intended to be code. Ordered lists are perfect for step-by-step instructions. We know an ordered list is ideal because if we rearranged the list items, the task of push changing to GitHub would not be successful therefore the meaning would change.
When you are looking group form fields such as a checklist look to use the list tags for greater clarity.
In my form I am wrapping my inputs with the <label></label> tags for simpler UX but you could also separate the input and label.
You'll notice some new tags <form><form> tags as a container for your form, <fieldset></fieldset> tags to group the related checkbox list items together, <legend></legend> tags to provide a title and give context to grouped elements, and the <button></button> tags to submit your form data to a server.
You have now learned how to create lists and when to use them on your website. Lists are a powerful tool to help organize your website content. Be sure to use them for your next project!
No fluff. Just real projects, real value, and the path from code to cash — one useful build at a time.