Jan 15 2008

HTML select with background (image or icon next to text)

Category: CSS,Designpaomic @ 9:28 pm

I’ve found out a nice article on how to place an icon or image next to a select option. This is the sample css:
<select name=”issuetype” id=”issuetype”>
<option value=”1″ class=”imagebacked” style=”background-image: url(/images/icons/bug.gif);” selected>
Bug
</option>
<option value=”2″ class=”imagebacked” style=”background-image: url(/images/icons/newfeature.gif);”>
New Feature
</option>
<option value=”3″ class=”imagebacked” style=”background-image: url(/images/icons/task.gif);”>
Task
</option>
<option value=”4″ class=”imagebacked” style=”background-image: url(/images/icons/improvement.gif);”>
Improvement
</option>
</select>

option.imagebacked {
padding: 2px 0 2px 20px;
background-repeat: no-repeat;
background-position: 1px 2px;
vertical-align: middle;
}

Here’s an example:

HTML select with background (image or icon next to text)

EDIT: actual dropdown

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • blinkbits
  • BlinkList
  • blogmarks
  • BlogMemes
  • blogtercimlap
  • Blue Dot
  • Book.mark.hu
  • Bumpzee
  • co.mments
  • De.lirio.us
  • Fark
  • feedmelinks
  • Fleck
  • Furl
  • Gwar
  • kick.ie
  • Linkter
  • Ma.gnolia
  • MyShare
  • Netscape
  • NewsVine
  • Scoopeo
  • Simpy
  • Slashdot
  • Smarking
  • Spurl
  • StumbleUpon
  • Taggly
  • Technorati
  • Webride
  • YahooMyWeb
Post Tagged:

4 Responses to “HTML select with background (image or icon next to text)”

  1. Luke says:

    This does not work at all. Why did not you rendered actual drop down instead of pasting image here. Hmm

  2. paomic says:

    Here’s the working version too. Take care to the ” you find in the text, they were changed to windows style ones, and screwed up all the css!

  3. Sparky says:

    Since this doesn’t work in IE, what is the point?

  4. Aubrey says:

    Since IE is not a web browsers rear end, who cares?

Leave a Reply