Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Font-Size for Button and Link

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?

like image 519
Kate Avatar asked Sep 30 '09 09:09

Kate


People also ask

How do you change the font size on a button?

To change the font size of a button, use the font-size property.

What size should website font be?

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.

How do I change the font size on a button in HTML?

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.


1 Answers

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.

like image 108
bobince Avatar answered Oct 11 '22 05:10

bobince