I need to divide into groups several <li>
elements in a list, is it possible?
(I know I an give each element different class names/separate into different <ul>
)
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
Have you considered using multiple-inheritance of CSS classes? This can be a bit messy to maintain, but it will solve the case of the same entry in multiple groups. The HTML looks something like this:
Here we have three groups (meat, vegetarian and vegan) and some toppings, like mushrooms and onions, are part of more that one group.
Have you considered nested UL's? I believe this would validate:
Your CSS trick was my first guess; too bad you can't use that.
If you need to separate into different groups items from one unordered list than they should belong to different lists isn't it OR should be grouped in an ordered list (many ULs in one OL).
If this is for presentation needs (to display one list on many columns) and you can solve a few constraints, the second technique in https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-5810687.html or explained also here : http://www.communitymx.com/content/article.cfm?page=2&cid=27F87
Such groups exist for select (optgroup) but obviously you can't separate the option elements because you must select only one of them so they should belong to the same element.
I believe your only options are the ones you've already identified, multiple lists or via classes, since for an
li
to be in the list defined by aul
or anol
, it must be the immediate child of thatul
/ol
(reference).According to the XHTML schema (or one the schema anyway), the only thing you put inside a
<ul>
is a<li>
, as described at http://www.w3.org/TR/2006/WD-xhtml-modularization-20060705/abstract_modules.html#s_listmoduleYou might tweak the appearance of the list items using CSS, by assigning different class values to the
<li>
elements.