Accordian with no JS - how to have 1 image be expanded upon opening the page?

I built an accordian slider on my site to display images. It uses only HTML & CSS - no JavaScript. I would like to keep it script free since it will be used on my home page and I want those with JS turned off or blocked to see a nice image when they first see the homepage.

It works great. It even switches to a vertical version for phones!

Only one problem: When first loading the page, all the images in the accordian show as the narrow version used for clicking. I want one of the images to show as the expanded / selected / clicked version (not sure what the proper term for that state is…) when the page first opens. Help!

You can see the accordian at the top of this page:
The pictures are not what I will use in the finished version. I just stuck some in there for testing. Click any one of the squished fork pictures and the accordian will start appearing as it was intended to.

I appreciate any and all ideas :slight_smile:


This might be a bit difficult to do without JavaScript.
Here’s my solution using jQuery (I noticed that you had included it in your page anyway).

What you want to do, is use jQuery to select the tab you want to have open. In my example I have chosen “about”.
Then, use jQuery to add a class of “sel” to the section with the id “about” (of course you can change this to any section you want.
The class “sel” is styled so that it displays the accordion picture as though it had been selected.
Then you attach an “onclick” event handler to remove the “sel” class, as soon as any of the other links are clicked.

People with JavaScript turned off, lose no functionality.
People with JS activated, get to see one of the pictures already selected.

Here is an example for you to play around with:

<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <title>Home 1</title>
    <link href="" rel="stylesheet">
    <link href="" rel="stylesheet">
     .sel a{display:none;}
     .sel img{display: block; height:300px; margin-top:0px;}
     section.sel {width:300px;}
    <div class="accordion horizontal">
      <section id="about">
        <a href="#about"><img src="" alt="Chillington Canterbury Fork" /></a>
        <img class="full-size" src="">
      <section id="services">
        <a href="#services"><img src="" alt="Chillington Canterbury Fork" /></a>
        <img class="full-size" src="">
      <section id="blog">
        <a href="#blog"><img src="" alt="Chillington Canterbury Fork" /></a>
        <img class="full-size" src="">
      <section id="portfolio">
        <a href="#portfolio"><img src="" alt="Chillington Canterbury Fork" /></a>
        <img class="full-size" src="">
      <section id="contact">
        <a href="#contact"><img src="" alt="Chillington Canterbury Fork" /></a>
        <img class="full-size" src="">
    <script src=""></script>
        $(".horizontal a").click(function(){

I hope that helps.
If you have any questions, just let me know.

This can be done using only CSS3 but it will only work in IE9+ and modern browsers.