Results 1 to 5 of 5

Thread: Divider in HTML Option Tag

  1. #1
    Join Date
    Dec 2008

    Unhappy Divider in HTML Option Tag


    I want to put a dashed line divider between a value in option and other options. A pseudocode is mentioned below. Please help How do I achieve this? The dashed line should not be allowed to be selected.

    <OPTION VALUE="TravelLeisure.html">Travel & Leisure
    <OPTION VALUE ""> -----------
    <OPTION VALUE="ymca.html">Waste Management
    <OPTION VALUE="WaterManagement.html">Water Management
    <OPTION VALUE="Welding.html">Welding

  2. #2
    Join Date
    Jun 2003
    HTML Code:
    <optgroup label='-------'>
      <option>Child option 1</option>
      <option>Child option 2</option>
      <option>Child option 3</option>
    If you are using PHP please use the [PHP] and [/PHP] forum tags for highlighting...
    The same applies to HTML and the forums [HTML][/HTML] tags.

  3. #3
    Join Date
    Jan 2008
    The optgroup html tag as scragar pointed out, will allow you to have an option group and you can label this group as '--------' so it will appear in the dropdown but be unselectable.

    Be sure to always close your tags. <option> should have a corresponding </option>.
    Need help bringing your website to life? http://www.nickelleon.com

  4. #4
    Join Date
    Nov 2002
    Baltimore, Maryland
    Quote Originally Posted by nickelleon View Post
    Be sure to always close your tags. <option> should have a corresponding </option>.
    No it shouldn't. Well, it doesn't have to have one and you are free to omit it as it pleases you. Don't submit to people who go about making up rules. There are plenty enough real rules out there that you do need to observe.
    <!ELEMENT OPTION - O (#PCDATA)         -- selectable choice -->
    That "O" signifies that the closing tag is optional for the element.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  5. #5
    Join Date
    Mar 2005
    Sydney, Australia
    Always closing tags makes your code easier to maintain.

    The rules that say the closing tags are optional are aimed at the browser writers not at web page writers. You need your own set of additional standards to follow when writing web pages in order to get more consistent easier to maintain pages and most such standards will state that you should always close all tags that are not self closing and should always include all optional tags (if you are writing pages for someone else then they will set those standards which they require you to follow). By doing so you can see exactly where those tags are rather than having to remember the rules that the browsers follow to add them. For example a lot of people have problems processing tables with JavaScript because they forget that the browser adds the optional tbody tag if it isn't there before the JavaScript sees the page so that the tbody is always there when the table is processed from JavaScript even when it is omitted from the HTML.

    Just because a browser is required to be able to handle when certain tags are omitted from your page doesn't mean that it is good practice to omit them, it just means that the browsers are required to be somewhat forgiving of poor coding practices.
    Last edited by felgall; 12-26-2008 at 04:13 PM.

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