Welcome to WebmasterWorld Guest from

Forum Moderators: incrediBILL

Message Too Old, No Replies

HTML select box default value

Can it be set to a specific option?



5:02 pm on Nov 6, 2003 (gmt 0)

10+ Year Member

Hi everyone,

Does anyone have any idea whether it's possible to set a default option for an html drop-down select box?

I have an ordered set of options, but would like to highlight an option as a default without necessarily having it first in the list. I had a faint recollection of it being as simple as

<option value="x" default>x</option>

but it doesn't seem to work (at least not for Mozilla anyway), so I must be wrong on that.

For a bonus point, is there a way to do it for 'select multiple' form elements?

Thanks in advance!


5:58 pm on Nov 6, 2003 (gmt 0)

WebmasterWorld Senior Member korkus2000 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

I believe selected instead of default should work. XHTML uses the nonshort-hand version, which I cannot remember off-hand.


6:00 pm on Nov 6, 2003 (gmt 0)

10+ Year Member

You're right - it is easy.
<option value="x" selected="selected">x</option>
which is XHTML compliant.

For multiple selectboxes just use the selected="selected" attribute for each option you need selected by default.


6:02 pm on Nov 6, 2003 (gmt 0)

10+ Year Member

This should work for xhtml:


6:56 pm on Nov 6, 2003 (gmt 0)

10+ Year Member

'selected="selected" ' works a treat.

Thanks for your help guys.


Featured Threads

Hot Threads This Week

Hot Threads This Month