How do I set this with css

<select name="cars">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="fiat">Fiat</option>
  <option value="audi">Audi</option>
</select>

Welcome to the forums, @amir1313.

Your question is rather vague; please can you explain what it is that you want to do, and show the CSS you have so far.

Off Topic
To get code blocks to show up correctly on the forums, you need to format them.

You can highlight your code, then use the </> button in the editor window, which will format it.

Or you can place three backticks ``` (top left key on US/UK keyboards) on a line before your code, and three on a line after your code. I find this approach easier, but unfortunately some European and other keyboards don’t have that character.

Not an easy goal, especially if you’re hoping for anything that will work cross browser.

My take after reading these two pages is the path of least resistance is to use JavaScript. - but that’s an awful big “least”

Some elements simply can’t be styled using CSS. These include all advanced user interface widgets such as range, color, or date controls as well as all the dropdown widgets, including <select>, <option>, <optgroup> and <datalist> elements. The file picker widget is also known not to be stylable at all. The new <progress> and <meter> elements also fall in this category.

The main issue with all these widgets comes from the fact that they have a very complex structure and CSS is not currently expressive enough to style all the subtle parts of those widgets. If you want to customize those widgets you have to rely on JavaScript to build a DOM tree you’ll be able to style. We’ll learn how to do this in the article How to build custom form widgets.

If you want to gain full control over form widgets, you have no choice but to rely on JavaScript. In the article How to build custom form widgets we will see how to do it on our own, but there are some very useful libraries out there that can help you:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.