user1007817
user1007817

Reputation:

CSS font cross browser compatibility

Ive read a bunch of tutorials on css cross compatibility which mentioned css reset sheets and a few other techniques, but I have yet to be able to create a website which has the font look the exact same on multiple browsers. I've switched from pt to px and incorporated a few other techniques which helped a little. Anyone know any better techniques?

Thanks

Upvotes: 2

Views: 3422

Answers (3)

Melros
Melros

Reputation: 1213

typekit might be also a solution for you beside those ones already mentioned.

https://typekit.com/

You must be aware that the users machine can only display the font you have choosen if they actually have these fonts on their computer.

f.e font-family: "Super Font", Helvetica, sans-serif;

If you have choosen a font called "Super Font" the users machine won't display this exact font, cause they might not have it on their machine. As declaired in your CSS the user machine will now have a look at the alternative "Helvetica", which the most of computers have on their machine, so "Helvetica" is gonna be displayed. If not even "Helvetica" is available the users machine will display a sans-serif font.

Here's a list of common fonts: Link

You already see, that they differ a bit in their look and font-weight cause they get rendered differently as Nate B already mentioned.

If you want to use your "Super Font" have a look at http://www.fontsquirrel.com/fontface as Jason Gennaro already recommended. There you'll be able not to only choose a font from a lot of free fonts but also use the @font-face generator to upload your own font and get all you need to build them right into your CSS, so that every machine will be able to display them (as far as @font-face is supported, Link). Even if it's already well supported, always declare a fallback font.

And here's a good blog post about the different ways to declare a font-size: Link

If you wanna dig a bit deeper and find out how to control the font-size over different devices, check out this article: Link

Upvotes: 0

Jason Gennaro
Jason Gennaro

Reputation: 34863

If you want the font to look exactly the same (size and all) and you are talking only about headers, then you might want to try using images.

Better, though, would be using @font-face and some generated fonts.

Check out FontSquirrel, which produces individual font files for several browers.

http://www.fontsquirrel.com/fontface

Upvotes: 1

Nate B
Nate B

Reputation: 6344

I don't know how exact you are talking, but it's never going to be exactly (to the pixel) the same in every browser. For example, I've noticed that OS X tends to make fonts wider (due to how it anti-aliases the text) than on Windows. Different browsers render fonts, even the same font, slightly differently, which can sometimes add up to several pixels, depending on your layout.

Upvotes: 0

Related Questions