Make an element in a multiple list unselectable???

N

Nick

Is it possible through css to make an element in a multiple list menu
unselectable. Im organizing my list by using titles...

+-------------+
| CATEGORY 1 |
| option 1 |
| option 2 |
| option 3 |
| CATEGORY 2 |
| option 1 |
| option 2 |
| option 3 |
| CATEGORY 3 |
| option 1 |
| option 2 |
| option 3 |
+-------------+

Id like to make the CATEGORIES unselectable. Thanks! -Nick
 
S

Steve Pugh

Is it possible through css to make an element in a multiple list menu
unselectable.

I'm presuming that you mean a <select> element rather than just an
ordinary list of links.

Why with CSS? CSS is for presentation. Making something unselectable
sounds like functionality to me.

The disabled attribute exists for the option element. But Windows IE
doesn't support it. :-(
Im organizing my list by using titles...

+-------------+
| CATEGORY 1 |
| option 1 |
| option 2 |
| option 3 |
| CATEGORY 2 |
| option 1 |
| option 2 |
| option 3 |
| CATEGORY 3 |
| option 1 |
| option 2 |
| option 3 |
+-------------+

Id like to make the CATEGORIES unselectable. Thanks! -Nick

Looks like you want the optgroup element.

<select name="foo">
<optgroup label="CATEGORY 1">
<option>option 1</option>
<option>option 2</option>
<option>option 3</option>
</optgroup>
<optgroup label="CATEGORY 2">
<option>option 1</option>
<option>option 2</option>
<option>option 3</option>
</optgroup>
<optgroup label="CATEGORY 3">
<option>option 1</option>
<option>option 2</option>
<option>option 3</option>
</optgroup>
</select>

Works in most modern browsers. In older browsers the options are
presented as normal but the labels aren't presented at all.

Steve
 
J

Jukka K. Korpela

Steve Pugh said:
Looks like you want the optgroup element.

Maybe. But in the absence of a URL to demonstrate what he is really
doing, my verdict is that he wants to create an expensive plastic
simulation of a hierarchic list of links.
Works in most modern browsers. In older browsers the options are
presented as normal but the labels aren't presented at all.

OK, let's say that it works in 95 % of browsing situations (as far as
_rendering_ is considered). The actual figure is probably somewhat
smaller. Anyway, even 5 % of possible users is a huge number. Is it
acceptable that the fallback has no label texts? I would answer:
yes, _if_ the labels are just for grouping options that are
understandable on their own. But it would be disastrous if e.g. some
options were identical, relying on the category labels for
disambiguation.

It's possible to create a hierarchic menu inside a form without using
optgroup, namely by using grouped radio buttons, see
http://www.cs.tut.fi/~jkorpela/forms/choices.html#optgroup

Massive crossposting triggered the usual "set Followup-To at random"
function. In future, the OP should spend some time in analyzing which
is _the group_ for his question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top