How can I indent categories and endless sub categories that I have in a select drop down menu using CSS?
1. Apple
2. Arts & Entertainment
1. Amusement
2. Art
3. Artists
1. A
1. a1
2. a2
2. B
3. C
4. D
3. Automotive
4. Network
5. Server
6. Web Design
1. CSS
2. HTML
You can’t do this with the
<select>element. You can’t have endless nested subcategory like you suggest, only one, with<optgroup>. Styling will also be difficult as the ability to style form elements differs from browser to browser.However, depending on your needs, the following solution might work:
For this, we are recreating the
selectelement using HTML lists. The markup would look like this:Then, with CSS, style it such that it fits your purpose:
Play around with it here: http://jsfiddle.net/thHFS/