I tried this simple html:
TEST FONT SIZE</br>
<input type="button" value="test bytton" style="font-size:20px">
<a style="font-size:20px">test link</a>
and found out that the font size of this button looks bigger than the font size of the link in spite of style. Does anybody know why style works differently for link and for button, and how to make them looks like the same?
To change the font size of a button, use the font-size property.
The default font size in all browsers tends to be approximately 16 pixels. A common practice is to set the root font-size to 62.5%, which translates the default 16px to approximately 10px.
Use OnClick() event for the button click & for moving the slider, use OnChange() event. In the case of a button click, use the DOM to access the <div> tag for changing the value of the font-size attribute from javascript itself.
The font-size is the same. But it looks different because the default page font is different from the default input-field font. Set the font-family
on both elements the same and they'll look the same.
I usually do:
body, input, button, select, option, textarea {
font-family: ...; /* whatever font */
}
body {
font-size: x%; /* whatever base font size I want */
}
input, button, select, option, textarea {
font-size: 100%;
}
to get consistent fonts over the page and form fields.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With