dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: Select Lengths

  1. #1
    Join Date
    May 2007
    Posts
    224

    Select Lengths

    Hello. I was wondering if you could set select menus to be of a certain length rather than stretching out for the longest option. Thanks on anything you give

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,614
    You can use the size attribute: http://www.w3.org/TR/html4/interact/...ef-size-SELECT

    This may not have the desired effect depending on what you actually want, plus which browser you use, as the specification leaves the actual implementation of select elements pretty much up to the user agent.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Nov 2008
    Location
    Akron, OH
    Posts
    233
    If I understand the question what you want to limit is the horizontal width of the display options associated with a particular select element.

    Short ans: yes
    <style>
    option{width:50px;}
    </style>
    <select style="width:50px">
    <option value=''>Opt1</option>
    <option value=''>Opt2Opt2</option>
    <option value=''>Opt3Opt3Opt3</option>
    <option value=''>Opt4Opt4Opt4Opt4</option>
    <option value=''>Opt5Opt5Opt5Opt5Opt5</option>
    <option value=''>Opt6Opt6Opt6Opt6Opt6Opt6</option>
    </select>

    BUT it will truncate the displayed values of the longer option elements (bad) and unfortunately 'word-wrap: break-word' is not support by any browser I've seen for 'option'.

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,614
    Ignore my previous reply, I misinterpreted what you were asking. You could use Javawebdog's suggestion to style the select element's width. You probably do not need to set the option elements' width unless you also need it to be limited for some reason.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    May 2007
    Posts
    224
    Ah yes I tried a simular thing and faced the truncation problem. I was pretty sure I had seen handle on one site or another. The maxlength application doesn't seem to be relevant now. There is generally one select I have which looks a bit out of place. It's rather rather long but of course the text in it is left aligned as well.

    Don't worry about it Nogdog

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles