Lists, Images, & Rich Media
Web applications don't just display blocks of paragraph text. They organize items into navigation bars, feature checklists, recipes, product grids, illustrations, and multimedia video players.
In this chapter, you will learn how to organize content using HTML lists and embed high-performance, accessible images, audio, and video.
1. Unordered Lists (<ul>)
An unordered list represents a collection of items where sequence does not alter meaning (e.g. grocery ingredients, navigation links, feature lists).
<ul> <li>HTML5 Semantic Structure</li> <li>CSS3 Flexbox and Grid Layouts</li> <li>JavaScript Modern ES6+ Features</li></ul><ul>: Wraps the list container.<li>: Represents each individual List Item. Only<li>elements are valid direct children of<ul>and<ol>.
By default, web browsers render unordered lists with bullet points. In modern web design, developers frequently use CSS (list-style: none; display: flex;) to turn <ul> lists into responsive horizontal navigation menus.
2. Ordered Lists (<ol>)
An ordered list represents a collection of items where sequence matters (e.g. step-by-step algorithms, cooking recipes, leaderboard rankings).
<ol> <li>Write clean, semantic HTML markup</li> <li>Style components with modern CSS</li> <li>Add interactivity with JavaScript</li> <li>Deploy application to production</li></ol>Browsers automatically prefix items with sequential numbers (1., 2., 3., etc.).
Advanced Ordered List Attributes
HTML provides native attributes to customize number sequencing without touching CSS:
| Attribute | Example | Result |
|---|---|---|
type="1" | <ol type="1"> | Default numbers (1, 2, 3...) |
type="A" | <ol type="A"> | Uppercase letters (A, B, C...) |
type="a" | <ol type="a"> | Lowercase letters (a, b, c...) |
type="I" | <ol type="I"> | Roman numerals (I, II, III...) |
start="5" | <ol start="5"> | Starts counting from 5 instead of 1 |
reversed | <ol reversed> | Counts down in reverse (e.g. Top 10 Countdown) |
3. Description Lists (<dl>)
A description list organizes key-value pairs, terms and definitions, or metadata records (e.g. glossaries, dictionary terms, technical specifications).
<dl> <dt>HTML</dt> <dd>HyperText Markup Language: the structural backbone of web pages.</dd> <dt>CSS</dt> <dd>Cascading Style Sheets: the presentation layer that styles colors and layout.</dd> <dt>DOM</dt> <dd>Document Object Model: the in-memory tree representation of an HTML document.</dd></dl><dl>: The Description List wrapper.<dt>: The Description Term (the key or word being defined).<dd>: The Description Details (the value, definition, or description).
4. Nested Lists
Lists can be nested inside one another to construct multi-level trees, such as file directory navigations or nested book outlines.
[!IMPORTANT] The nested sub-list must be placed inside the parent
<li>tag, not directly between<li>tags!
<ul> <li>Frontend Development <ul> <li>HTML5 Fundamentals</li> <li>CSS3 Styling</li> <li>JavaScript & React</li> </ul> </li> <li>Backend Development <ul> <li>Node.js & Express</li> <li>PostgreSQL & Prisma</li> </ul> </li></ul>5. Embedding Images: The <img> Element
The <img> tag embeds visual images (JPEG, PNG, SVG, WebP, AVIF) into an HTML page. Because it displays an external resource and cannot contain child elements, it is a void (self-closing) element.
<img src="/images/thinkora-banner.webp" alt="Thinkora learning dashboard displaying interactive coding lessons" width="800" height="450" loading="lazy">Essential Image Attributes
src(Source): The URL or file path where the image is stored.alt(Alternative Text): A concise text description of the image.- Crucial for accessibility: Screen readers speak this text aloud to visually impaired learners.
- Crucial for network fallbacks: Displayed if the image fails to load or the connection is broken.
- Crucial for SEO: Search engine bots index the
alttext to understand image context.
widthandheight: Always specify explicit dimensional aspect ratios. This reserves screen space before the image downloads, preventing annoying layout jumps known as Cumulative Layout Shift (CLS).loading="lazy": Defers loading images that are below the fold until the user scrolls near them, dramatically improving initial page load speed.
6. Captioned Media: <figure> & <figcaption>
When you want to display an illustration, diagram, code snippet, or photo accompanied by a self-contained caption, use <figure> and <figcaption>:
<figure> <img src="/diagrams/box-model.svg" alt="Diagram illustrating CSS Box Model content, padding, border, and margin layers" width="600" height="300" > <figcaption>Figure 1.1: The CSS Box Model hierarchy rendered by modern browsers.</figcaption></figure>7. Native Video & Audio Players
Before HTML5, embedding audio or video required third-party plugins like Adobe Flash. Today, HTML provides native multimedia tags with built-in playback controls:
Embedding Video (<video>)
<video controls width="640" poster="/previews/intro-poster.webp"> <source src="/videos/intro.mp4" type="video/mp4"> <source src="/videos/intro.webm" type="video/webm"> <p>Your browser does not support HTML5 video. <a href="/videos/intro.mp4">Download the video</a>.</p></video>controls: Displays default browser play, pause, volume, and fullscreen buttons.poster: An image displayed while the video downloads or before playback begins.<source>: Lets you provide multiple video formats; the browser automatically chooses the first codec it supports.
Embedding Audio (<audio>)
<audio controls preload="metadata"> <source src="/podcasts/ep-1.mp3" type="audio/mpeg"> <source src="/podcasts/ep-1.ogg" type="audio/ogg"> <p>Your browser does not support HTML5 audio.</p></audio>8. Flashcards
Why is the 'alt' attribute mandatory on <img> elements?
Why should you always include 'width' and 'height' on <img> tags?
What is the proper way to nest a sub-list in HTML?
- or
- element, rather than as a sibling between
- tags.
- must be placed inside the parent