Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS Online Registration Form

Kate Massie
seal-mask
.a{fill-rule:evenodd;}techdegree
Kate Massie
Front End Web Development Techdegree Student 7,062 Points

Styling a select box

Hi, can anyone tell me how to add a border to a select box?

I want to add it on the :focus state. Select:focus isn't working, and neither is :focus with the class of the surrounding div.

I'm working on the Online Registration Form for the third Techdegree project.

Thank you!

2 Answers

Steven Parker
Steven Parker
231,248 Points

Only techdegree students can use your link, but I built a little test using this HTML and CSS:

code.html
<div>
  Focus the box:
  <select name="x" id="x">
    <option value="1">one</option>
    <option value="2">two</option>
    <option value="3">three</option>
  </select>
</div>
styles.css
select:focus { border: 4px solid red; }

The border appears as expected when the select box has focus. Maybe it's a browser issue? I'm using Chrome.

Did you mean to use hover instead of focus? I tried that too, it also worked as expected.

Kate Massie
seal-mask
.a{fill-rule:evenodd;}techdegree
Kate Massie
Front End Web Development Techdegree Student 7,062 Points

Hi Steven, thanks for your comment! I'm using Chrome too, and I definitely mean focus. That's the command I'm using, too. I think I might try rebuilding the form; otherwise I have no idea.