The Wayback Machine - https://web.archive.org/web/20250122144131/https://www.geeksforgeeks.org/how-to-add-images-to-a-list-using-html/
Open In App

How to Add Images to a List Using HTML?

Last Updated : 14 Jan, 2025
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

To add images to a list using HTML, you can place <img> elements within list items (<li>). This allows you to create ordered or unordered lists that contain images as their content.

Example of Adding Images to a List

Here’s how you can achieve this

Example 1: Unordered List with Images

HTML
<html>
<head>
 <style>
   img{
     height:50px;
     width:50px;

   }
   ul{
     display:flex;
     flex-direction:column;
     justify-content:center;
     gap:10px;
   }
  </style>
  
</head>
<body>
  <h2>Unordered List with Images</h2>
  <ul>
    <li><img src="https://media.geeksforgeeks.org/wp-content/uploads/20241228163555788894/puzzle.webp" alt="Placeholder Image 1"> </li>
    <li><img src="https://media.geeksforgeeks.org/wp-content/uploads/20241228102812942963/0_ilw552fVUGbwIzbE.jpg"> </li>
    <li><img src="https://media.geeksforgeeks.org/wp-content/uploads/20241228115736661074/Screenshot-2024-12-28-115706.png" alt="Placeholder Image 3"></li>
  </ul>
</body>
</html>


Example 2: Ordered List with Images

HTML
<html>
<head>
   <style>
   img{
     height:40px;
     width:40px;
     margin-top:20px;
   }
   ul{
     display:flex;
     flex-direction:column;
     justify-content:center;
   }
  </style>
</head>
<body>
  <h2>Ordered List with Images</h2>
  <ol>
    <li><img src="https://media.geeksforgeeks.org/wp-content/uploads/20241227190422405339/How-to-Add-a-Link-to-Instagram-Story.webp" alt="Placeholder Image A"> </li>
    <li><img src="https://media.geeksforgeeks.org/wp-content/uploads/20241227174833908308/How-To-Insert-a-Checkbox-in-Word.webp" alt="Placeholder Image B"> </li>
    <li><img src="https://media.geeksforgeeks.org/wp-content/uploads/20241202120524734939/lion1.png" alt="Placeholder Image C"> </li>
  </ol>
</body>
</html>

Explanation:

  1. List Elements: Use <ul> for unordered lists or <ol> for ordered lists, and wrap each item in <li> tags.
  2. Image Tags: Within each <li>, use the <img> tag to display an image.
    • src: Specifies the path to the image.
    • alt: Provides alternative text for accessibility and when the image fails to load.
  3. Additional Text: You can add text along with the images if desired, as shown in the examples.

Next Article
Article Tags :

Similar Reads

three90RightbarBannerImg