0

Possible Duplicate:
Why should I use ‘li’ instead of ‘div’?

I'm figuring out how to make a perfect slideshow/homepage slider. Many tutorials and examples use li elements for each slide, while others use divs. What would be the benefit of using list items? It looks convoluted to me: normally divs are used to separated content fields.

Community
  • 1
  • 1
kslstn
  • 1,407
  • 1
  • 14
  • 34

3 Answers3

2

It will mostly be for semantic reasons - you're storing/accessing a list of content items, it makes sense to store it in a list conceptually.

martinwnet
  • 571
  • 2
  • 4
  • 10
1
  • div is used for logical grouping of enclosed elements.
  • li is used to define list items.

If you need to express a list of items, using 'li' is more semantically appropriate. In this case, you have to represent a list of images in the slider. So it is better to use 'li' instead of 'div'.

Although it's a good practice to use lists for this scenario, there's no technical advantage choosing one over the other.

Further reading: Why should I use 'li' instead of 'div'?

Community
  • 1
  • 1
giftcv
  • 1,670
  • 15
  • 23
0

I see two potential advantages of using divs to lis.

  1. The div instructions in your CSS may already have the margin and/or padding attributes that you'd like to implement with the inner items of your jQuery plug-in (or slider in this case).
  2. Templating can be easier with divs because the inner items don't need to be lis.

Otherwise, I agree with the other answers.

  • li is much more consistent with the semantic model.
Jim G.
  • 15,141
  • 22
  • 103
  • 166