VOOZH about

URL: https://www.geeksforgeeks.org/web-templates/how-to-create-image-accordion-using-html-and-css/

⇱ How to Create Image Accordion using HTML and CSS ? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Create Image Accordion using HTML and CSS ?

Last Updated : 5 Aug, 2025

In this article, we will see how to create an image accordion using HTML & CSS that is basically used for advertising purposes on e-commerce websites. An Accordion is often used to open multiple sections at full width & also content pushes the page content downward.

Approach:

  • Create an HTML file that will contain the different types of images for advertisement.
  • Create a CSS style that will provide some animation effects to the web page elements.

HTML Code:

  • Create an HTML file, named index.html, that contains a title to our webpage using the <title> tag. It should be placed inside the <head> tag.
  • Link the CSS file that provides all the animation's effects to our HTML. This is also placed inside the <head> tag.
  • In the body section, create a class main_box that has the corresponding div classes containing the different advertisements images.

Example: Here is the implementation of the above-explained steps.

CSS Code: CSS is used to provide different types of animations and effects to our HTML page so that it looks interactive to all users. In CSS, we will note the following points:

  • Restore all the browser effects.
  • Use classes and ids to give effects to HTML elements.
  • Use of :hover to use hover effects.

Output: In this way, you can create your own advertisement section!.

Comment