DEV Community

loading...
Cover image for 15 Best CSS Accordion Designs You’ve Never 👀 Seen Before

15 Best CSS Accordion Designs You’ve Never 👀 Seen Before

Stackfindover
Hii i'm Rahul Jangir, a tech geek, designing enthusiast and an online expert, graduated in technology who is addicted to front-end development.
・3 min read

Hello Friends, I have listed over 15 best css accordion designs made with HTML, CSS, and JS. Check out these excellent accordion examples which are available on Codepen.

Awesome Accordion Design 2021 step by step

Step 1 — Creating a New Project

In this step, we need to create a new project folder and files(index.html, style.css) for creating a simple accordion design. In the next step, you will start creating the structure of the webpage.

Step 2 — Setting Up the basic structure

In this step, we will add the HTML code to create the basic structure of the project.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>How to create accordion with css only</title>
    <link rel="stylesheet" href="style.css">
    <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@200;400&display=swap" rel="stylesheet">
</head>
<body>

</body>
</html>
Enter fullscreen mode Exit fullscreen mode

This is the base structure of most web pages that use HTML.

Add the following code inside the <body> tag:

 <div class="accordion_outer">
        <div class="container">
            <details>
                <summary>Section 1</summary>
                <div class="details">
                    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
                </div>
            </details>
            <details>
                <summary>Section 2</summary>
                <div class="details">
                    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
                </div>
            </details>
            <details>
                <summary>Section 3</summary>
                <div class="details">
                    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
                </div>
            </details>
            <details>
                <summary>Section 4</summary>
                <div class="details">
                    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
                </div>
            </details>
        </div>
    </div>
Enter fullscreen mode Exit fullscreen mode

Step 3 — Adding Styles for the Classes

In this step, we will add styles to the section class Inside style.css file

* {
    padding: 0;
    margin: 0;
    font-family: 'IBM Plex Sans', sans-serif;
}
html,body {
  background: #dae9f9;
}

.container {
  width: 95%;
  max-width: 1140px;
  margin: auto;
}
.accordion_outer {
  padding: 50px 0;
}
details {
  background: #f2f4f6;
  padding: 10px;
  font-size: 18px;
  margin-bottom: 10px;
  cursor: pointer;
}
.details {
  background: #fff;
  padding: 10px;
  margin-top: 10px;
  cursor: auto;
}
Enter fullscreen mode Exit fullscreen mode

#Final Result

Best Collection of Accordion design

In this collection, I have listed over 10+ best accordion designs made with HTML, CSS and JavaScript. Check out these awesome CSS accordion examples which are available on Codepen.

#1 Accordion in vanilla js

#2 Pure CSS Accordion 2.0

#3 Frontend Mentor | FAQ Accordion Card

#4 Multi theme accordion

#5 Bootstrap 5.0 accordion

List of css accordion

You may like these also:)

  1. 🔥 Best 25+ Stunning CSS Fire Animations 2021
  2. 100% Free Best CSS Card Design For Your Website
  3. How to build a JavaScript Random Quote Generator

Discussion (3)

Collapse
posandu profile image
Posandu Mapa

Who says "CSS Accordion Designs You’ve Never 👀 Seen Before " for this post ? Because these are the most used accordion designs !

Collapse
afif profile image
Temani Afif

and what to do with the click-bait titles? 😉 . Gold rule on DEV: if you see a title saying "you never seen before", "you didn't know", "hidden trick nobody knows","no one did this before", etc, etc .. be sure that you will find something common and well known.

Collapse
afif profile image
Temani Afif

please give proper attribution to other people works as a sign of "respect". Actually you are making it like it's your own work.