5

Need to capitalize the first letter of the select box option tag.

Here it is what tried:

HTML:

<select>
  <option class="selected">test1</option>
  <option>test2</option>
  <option>test3</option>
</select>

CSS:

select option.selected::first-letter{
  text-transform:capitalize;
}
ketan
  • 19,129
  • 42
  • 60
  • 98
  • 1
    possible some answer dublicate http://stackoverflow.com/questions/34188117/how-to-capitalize-only-the-first-letter-of-an-html-option-element-using-css – Ivin Raj Dec 15 '15 at 06:03
  • Just `select {text-transform:capitalize}` should work. Here is a Working Fiddle to demonstrate: http://jsfiddle.net/jf0ahqvo/embedded/result/ – sachin Dec 15 '15 at 06:05
  • I don't think it is duplicate question. Because here OP want selected option first letter capital only. – ketan Dec 15 '15 at 06:24

1 Answers1

-2

Try this code. if you want selected option capitalized as well then you can do as below code in HTML. This should work in most browsers.

select option {
  text-transform: capitalize;
 }

<select>
  <option class="selected">Test1</option>
  <option>test2</option>
  <option>test3</option>
</select>
Chirag Mishra
  • 93
  • 1
  • 4
Prajwal Shrestha
  • 524
  • 3
  • 12