Bulletproof Tuesdays – Ch. 1 – Flexible Text
If you take a look at these screenshots it becomes obvious that not all browsers are created equal. Even if they are fed the exact same code. So what do you do? Based upon what I had read earlier on The Noodle Incident site I’ve been setting the body text size to 76% and adjusting the rest of the text using em’s.
Dan Cederholm on the other hand recommends the Bulletproof technique of setting the base size using absolute-size keywords. Basically you want to set your body font-size to: small and adjust the headings, etc. using percentages. So even if you text size isn’t perfectly consistent across browsers the ratio between your font sizes will be.
Letting go of “pixel precision” and allowing your users to adjust the font size as they see necessary is a big step in the right direction. So what exactly should your CSS look like? Well the simplified box model hack (sbmh) is probably the best. It solves an IE5/Win bug that renders text larger than it is in other browsers. The sbmh looks like:
body {
font-size: small;
}
* html body {
font-size: x-small; /* for IE5/Win */
f\ont-size: small; /* for other IE versions */
}
So once you’ve got your set your body font-size to small, what do you do next? Now you can use percentage to adjust the rest of the text sizes. So you would have something that looks like:
body {
font-size: small;
}
h1 {
font-size: 150%;
}
There are a few more pitfalls to deal with when using this method, but I’ll let Dan tell you about that in the book. This chapter is pretty basic and straight forward, and next week should be more interesting. I had a few challenges implementing the keyword method, I had to make adjustments to some line-heights. When changing em’s to percentages I just changed 1.1em to 110%. Overall it seems to work great and I bet you can’t even tell I changed anything, which is the whole point.
For more reading on the subject of text sizing check out:
Size Matters
The Noodle Incident
Popularity: 7% [?]
1 Trackback(s)
- From Michael Doig - An Intelligent Mix Of Design And Marketing » Blog Archive » Bulletproof Tuesdays - A Read-Along | Mar 17, 2006
