11

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?

BrechtDeMan
  • 6,589
  • 4
  • 24
  • 25
Kate
  • 751
  • 1
  • 12
  • 26

4 Answers4

26

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.

bobince
  • 528,062
  • 107
  • 651
  • 834
  • I set same font-family for link and button and get the same result. Text inside button and link have different size. – Kate Sep 30 '09 at 10:54
  • Works for me, in any browser. Post your exact test case that isn't working? – bobince Sep 30 '09 at 11:29
5

Had the same problem in Chrome, later figured out that key cause was

body {
    -webkit-font-smoothing: antialiased
}

changing this to

body {
    -webkit-font-smoothing: subpixel-antialiased;
}

fixed it.

Ish
  • 28,486
  • 11
  • 60
  • 77
  • Thanks, I had a similar problem (the link was using the `antialiased` setting, where my `` tag was using `auto`). – MaxGabriel Jul 11 '14 at 01:46
1

Looks the same to me, tested on Firefox, IE6 and Chrome: http://jsbin.com/oveze
Please keep in mind:

  • This depends on the browser and its defaults, and may also be different depending on the operating system.
  • Very often there's a different font for buttons and input fields. Set it too.
  • Anti-aliasing or ClearType can cause a slight difference when you don't have the same colors (background and font).
Kobi
  • 135,331
  • 41
  • 252
  • 292
-5

You should not use much CSS for buttons, because their display depends on the users operating system.

Instead you can use for example images.

brainfck
  • 9,286
  • 7
  • 28
  • 29