Build a simple semantically valid carousel from scratch (part 1)

In the latest day I wonder how to build a carousel like iTunes coverflow but more simpler. First of all we’ll make a checklist of requirements, second we’ll make a scratch of the carousel, third we’ll analyze each element of the scratch, which is their role in the context and at the end we will develop the jQuery solution.

Requirements and scratches

Our carousel should have 5 visible elements at time: one in the center and other on both sides of central element. The elements would become transparent as they assumes a far position from the center of the carousel. The distant elements, must be smaller than the intermediate elements, which in turn must be smaller than the central element. Starting with the above idea in mind, I made a scratch of the carousel as you can see in the image below. So, we have a main container that encloses our carousel, the item container and two navigation elements placed on both left and right sides of the carousel, inside the main container. Items into the carousel will be classified depending on their current position:

  • Current Item is the current visible item in the carousel
  • Near Item is the first item near the carousel, placed in the middle of our carousel..
  • Far Item is the item at the border of the carousel

At this point is obviously clear how to structure the carousel to make it semantically valid.

  1. The carousel is a list of items. Sorted? Unordered? It does not matter, it could matter only if think that the information inside the carousel makes their sense if read sequentially, else we can use an unordered list.
  2. The navigation items are simply hyperlinks to nothing.
  3. The main container is a “div” element. It can host inline elements and blocklevel elements (the unodered list) and inline elements (the hyperlinks).

I was just thinking about that: But what we need to create by hand? And what not? We will create the main container and the unordered list too, but we will not create the navigation links because they will be produced by javascript.

<div id="my-carousel">
        <li>Item #1</li>
        <li>Item #2</li>
        <li>Item #3</li>
        <li>Item #4</li>
        <li>Item #5</li>

The above structure, without stylesheet and javascript, will be semantically valid. The next week we will produce the CSS and wetting our hands with jQuery plugin developement. Stay tuned!


5 risposte a “Build a simple semantically valid carousel from scratch (part 1)”

  1. […] we’ve made a proof analysis of the Carousel, thinking about it’s structure and making it strictly semantic, we’ve discussed about […]

  2. Hey Diego,

    written a similar piece not too long ago, using data- attributes and a more strict html structure build with javascript.

  3. Interesting aproach Niels. I’ve not used HTML5 in this tutorial because it’s still a Working Draft and could be changed in the will. But you find me totally agree on you except for the div for navigation link: I would put them into a



  4. I was wondering: how you draw those sketches? They’re cool for some presentation!

    1. Those sketches are designed using Pencil Sketching Tools by Evolus.