I have an ol that I'd like to display in four columns. For accessibility reasons, I'd like to keep it all in a single list. I think the only thing lists are allowed to hold (in strict XHTML, anyway) is the li element, so I can't wrap div's around the appropriate items. The only technique I can think of is to give corresponding class names to the items that will be in the first, second, third, and fourth column, and then to jump through all kinds of CSS hoops to make it look right.
Is there any other way to do this?
I feared as much. Thanks for the awesome resources, though. Those look pretty cool.
this is great. I've used
content: " - <" attr(href) ">";
but never knew about the counter stuff.
Hi, there is a modeul in CSS3 for multi column, however only webkit currently has support (and I think the latest versions of FF)
However it's be best to just create your HTML to simulate the multi columns (aka set up the HTML like that)
If you don't understand what I mean then shout.
The only technique I can think of is to give corresponding class names to the items that will be in the first, second, third, and fourth column, and then to jump through all kinds of CSS hoops to make it look right.
You have pretty much answered your own question if you want it to be a single OL. That was actually one of the CSS Quizzes recently and there were many hoops to jump through. In fact IE6/7 had to get a completely different stylesheet to make them work due to the broken float model and other issues.
I will just point you to the thread and you can see for yourself what it was all about. As it is explained in the thread, CSS3 offers a Multi Column Module but it is not a cross browser solution.
Test Your CSS Skills Number 30 - Multi columns
Here are my examples from that quiz -
As far as a cross browser version without having to "jump through hoops" the easiest thing to do is simply float four columns left and use four separate OLs'. Our resident html guru "AutisticCuckoo" has provided a very elegant solution in this recent thread that uses a pseudo :before block on the LI with a counter reset to continue the decimal sequence into each column.
Restart and ordered list at a particular number
All credit goes to Tommy for the code and script in the link below, all I did was turn it into a three column OL based off of the basic structure shown in the thread.
I would probably use that last method if I needed full browsers support without a lot of complicated css.
Hope that helps