Default user-agent font sizes

Friday 19th February

Even the most basic styling can reveal differences in user agent styles

Recently, whilst experimenting with text-scaling, I noticed an IE curiosity I’d never come across before. To demonstrate, it begins with some very simple markup:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
	"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>Font sizing</title>
</head>
<body>
	<h1>Main heading</h1>
	<h2>Secondary heading</h2>
	<p>Standard paragraph with a bit of sample text.</p>
</body>
</html>

This is about as simple as HTML can get, and the results are as expected:

Default styling on a simple document, viewed in Firefox 3.6

The same simple styling in Internet Explorer 7.0

Apart from some minor spacing differences, those two renderings are just about identical. However, let’s say we want to double the entire document’s text size:

body { font-size: 200%; }

Again, pretty straightforward stuff: the body, and all contained elements that will inherit that style, should scale by a factor of two:

The basic document with a 200% font size set on the body, viewed in Firefox …

… and in IE.

Hang on — what happened in IE? Rather than doubling all font sizes, only the main paragraph text has changed, and is now bigger than the secondary heading and the same size as the main heading: definitely not what was intended.

It’s pretty obvious what’s going on here: IE’s user agent styling must set headings in absolute font sizes! This will rarely cause any problems, because site designs almost always explicitly define their own font sizes, but it’s certainly one to watch out for, particularly if you’re doing any work with text scaling using CSS.


Tweet

Comments

Mon 13 Dec 2010 02:08

Atlanta Injury Lawyer

Atlanta Injury Lawyer said:

I like your information.

Tue 5 Apr 2011 17:47

jiro brasen

jiro brasen said:

Love the post. Thank you for sharing it with us. <a href="http://www.premierpixels.com">Las Vegas Web Design</a>

Fri 17 Jun 2011 22:20

Jacksonville Divorce Attorney

Jacksonville Divorce Attorney said:

Good blog, made a lot more sense after you explained it, thanks.

Thu 26 Jan 2012 01:05

auto loan ohio

auto loan ohio said:

Rather than doubling all font sizes, only the main paragraph text has changed, and is now bigger than the secondary heading and the same size as the main heading: definitely not what was intended.

Thu 26 Jan 2012 01:05

auto loan ohio

auto loan ohio said:

Rather than doubling all font sizes, only the main paragraph text has changed, and is now bigger than the secondary heading and the same size as the main heading: definitely not what was intended.

Leave a comment