By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,656 Members | 800 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,656 IT Pros & Developers. It's quick & easy.

Make an element in a multiple list unselectable???

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
nb********@hotmail.com (Nick) wrote:
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

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 20 '05 #2

P: n/a
Steve Pugh <st***@pugh.net> wrote:
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....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.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.