• blog
  • Build an Accordion Without JavaScript

October 7,2021

Build an Accordion Without JavaScript

byIsev Team Isev Team

accordion-v2
In the pursuit of web performance, we are all looking to come up with clever solutions to make our websites load faster. One way many of us do this is coming up with and stealing (which in this case, the latter is more appropriate) ways of writing less JavaScript.

Many websites I work on include an FAQ section, and nine times out of ten I end up building some form of accordion. But recently I saw a method of building a mobile menu without the use of JavaScript, and I wondered if I could use the same method to build an accordion.

See the Pen Building an Accordion without JavaScript – Part I by Michael (@mjtweaver) on CodePen.

The above pen really simply demonstrates how we can achieve this. We use the label to use as the question, and we also include a checkbox. The checkbox is hidden from view. When we click on the label, it checks the input and then we can use this to display the answer. You’ll notice here we use the general sibling combinator or ~. I wrote some more information on this here. The above example was very simple, how about a styled up version?

After searching on Google, I know others have also used this solution in the past, so it may not be new to you, but it would interesting to get your thoughts.

As a note on browser compatibility, the only thing you have to really consider is the general sibling selector, information can be found here.

Continue Reading

What sets our website designs apart?

Website design goes beyond aesthetics; it's about crafting an experience that keeps your audience engaged and encourages them to return to your business.

Avatar
Leanne October 18th, 2024
Understanding Website Architecture: A Comprehensive Guide

Did you know that, on average, users spend only 54 seconds on a website? In that brief moment, it’s crucial to grab their attention, engage them, and make them want to stay on your website. So, if your site is difficult to navigate, visitors are more likely to leave and seek an easier experience elsewhere. … Continued

Isev Team
Isev Team October 7th, 2024
How to Get a High Quality Website

One of our favourite quotes is “If it’s done right, it’ll last forever”, a statement that is specifically true for how important a quality website company, with talented developers and designers is. Sure, you could get a website built for you, or even build one yourself both at a lower cost than professional website builders … Continued

Isev Team
Isev Team September 24th, 2024
The Customer Journey: Tips and best practices

This article looks in detail at both the customer journey and the conversion funnel, analysing how they function and how they work hand in hand.

Avatar
Leanne August 15th, 2024