SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru DeNasio's Avatar
    Join Date
    May 2001
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Making part of an <option> bold

    I have the following code on my site:

    Code:
    <form action="script.php" method="post">
    <p><select name="folderid">
    <option value="">- select a folder -</option>
    <option value="1">Public: folder 1</option>
    <option value="2">Public: folder 2</option>
    <option value="3">Private: folder 3</option>
    </select>
    <p><input type="submit" value=" Next " />
    </form>
    Is it possible to use CSS and make the "Public:" bold but not the rest? I need it to be something like this:

    Public: folder 1
    Public: folder 2
    Private: folder 3
    Ballot-Box.net - free polls for webmasters
    FormLog.com - free form processor

  2. #2
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,107
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    <option value="1"><strong>Public/strong>folder 1</option> ...

    Edit: Hehe check out the smiley!
    That's
    Code:
    <option value="1"><strong>Public:</strong>folder 1</option> ...

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope. According to the DTD,
    Code:
    <!ELEMENT OPTION - O (#PCDATA)>
    You can't have any markup whatsoever inside an OPTION element. Only text, which may have entity references inside it.
    Birnam wood is come to Dunsinane

  4. #4
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,107
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    Who wants a valid page anyways..

    You can do this sort of thing.. http://www.sitepoint.com/contact
    Check out the Reason for Contact drop down - it's not exactly what you asked for though.

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It doesn't primarily have to do with validity.
    Markup inside an OPTION element should be rendered literally. In your example, the displayed text should be '<strong>Public&#58;</strong>folder 1'.
    Birnam wood is come to Dunsinane

  6. #6
    SitePoint Guru DeNasio's Avatar
    Join Date
    May 2001
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The only way to do this is to use

    Code:
    <optgroup label="Public">
    Ballot-Box.net - free polls for webmasters
    FormLog.com - free form processor

  7. #7
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,107
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    If you want to use the standard form elements, I think so.(but its likely im wrong, Tommy ?)
    You could always do what Google does and recreate the form elements using your own customized elements, but thats not very semantic now is it?


Bookmarks

Posting Permissions

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