Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

font-smoothing not applied to buttons

I have used this snippet to prevent webkit from changing antialiasing when using CSS transforms:

html{ -webkit-font-smoothing: antialiased; }

This works fine for most cases, however I noticed some weirdness in chrome when playing around with Bootstrap using this HTML:

<button class="btn btn-inverse">John Doe</button>
<a class="btn btn-inverse">John Doe</a>​

This is how it looks in OSX/Chrome:

enter image description here

Fiddle: http://jsfiddle.net/hY2J7/. In fact, it seems that it is not applied to buttons at all. Is there a safer technique to trigger the same antialiasing in webkit for all elements?

like image 422
David Hellsing Avatar asked Nov 25 '12 23:11

David Hellsing


People also ask

Should I use WebKit font smoothing?

If you're design is placing text onto a dark background then you have a good reason to look towards using the WebKit and Firefox prefixed font-smoothing options to make the text look lighter, but you should be warned that these only work on Mac and OSX and leaves the billions of other users with a sub-standard view.

How do I make text look smooth in CSS?

auto - Allow the browser to select an optimization for font smoothing, typically grayscale . grayscale - Render text with grayscale antialiasing, as opposed to the subpixel. Switching from subpixel rendering to antialiasing for light text on dark backgrounds makes it look lighter.

What is font antialiasing?

Antialiasing refers to the smoothing of jagged edges of drawn graphics and text to improve their appearance or readability.


2 Answers

Your answer is:

* {-webkit-font-smoothing: antialiased;}​
like image 99
Francis Kim Avatar answered Sep 18 '22 09:09

Francis Kim


As the -webkit-font-smoothing is not a standard property, its inheritance rules are not properly defined.

In this case, for button elements, the default value for -webkit-font-smoothing is 'auto' not 'inherit'.

You can solve this by adding this css rule:

button {
    -webkit-font-smoothing: inherit;
}

Now, the button element should inherit whatever values you've set it to.

You may also want to run some other tests to see if any other elements also exhibit the same behaviour.

like image 24
Clark Pan Avatar answered Sep 20 '22 09:09

Clark Pan