Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change HTML dropdown option font size [duplicate]

Tags:

html

css

I have this simple HTML dropdown menu:

<select>
    <option style="font-size:50px;">Test</option>
</select>

I can't find a way to increase the font size of the option. The font-size property is being ignored for some reason. Is this a bug or what?

Thanks

like image 641
Michael Samuel Avatar asked Jul 15 '14 15:07

Michael Samuel


People also ask

How to change the font style by option dropdown?

To change the font style by option dropdown: The font values can be passed in option tags using option value. The value attribute specifies the value to be sent when a form is submitted. So after the value to be sent is selected, we set the fontFamily property for the text in the element to the selected value as specified in the above syntax.

How do I set the font-size for my HTML content?

Always use the proper HTML tags, like <h1> - <h6> for headings and <p> for paragraphs. The font-size value can be an absolute, or relative size. Note: If you do not specify a font size, the default size for normal text, like paragraphs, is 16px (16px=1em). Tip: If you use pixels, you can still use the zoom tool to resize the entire page.

What is the default font size for text in HTML?

Note: If you do not specify a font size, the default size for normal text, like paragraphs, is 16px (16px=1em). Tip: If you use pixels, you can still use the zoom tool to resize the entire page. To allow users to resize the text (in the browser menu), many developers use em instead of pixels.

How to change the font style of the text in JavaScript?

So after the value to be sent is selected, we set the fontFamily property for the text in the element to the selected value as specified in the above syntax. In the javascript function, here changeFontStyle (), the fontFamily property value is set to the font value of the option selected. By default, it is set to Times New Roman.


4 Answers

Have you tried putting it on your <select> element?

<select style="font-size:50px;">
    <option>Test</option>
</select>

fiddle: http://jsfiddle.net/tCw8M/

Or with a stylesheet:

select {
   font-size: 50px;
}

fiddle: http://jsfiddle.net/tCw8M/2/

like image 193
underbar Avatar answered Nov 16 '22 01:11

underbar


The font size option needs to be on the select tag, not the option tag:

<select style="font-size:50px;">
     <option >Test</option>
</select>

Whether you do it directly to the tag or in a css file selecting the tag is up to you.

like image 23
David Morin Avatar answered Nov 16 '22 02:11

David Morin


You should turn off the default OS styling with: -webkit-appearance: none;

DEMO here

like image 26
Krupal Shah Avatar answered Nov 16 '22 02:11

Krupal Shah


You have to apply the style in select not in option like:

select{
    font-size:50px;
}

fiddle

like image 32
Alex Char Avatar answered Nov 16 '22 02:11

Alex Char