When I tweeted this and then followed up with this, I got comments like this. That comment has a perfectly valid point.

We often talk about screen resolution, which is not the relevant statistic when thinking about what space our website’s visitors have available. The relevant statistic is browser window size. So why do we talk about screen resolution so much? Well probably because in the most popular analytics software in the world, Google Analytics, it’s the only data you get.

(The Google Analytics team is aware of this)

And so, what are we to do? Well, start measuring browser size, for one.

But first, a word.

What if we figured out all kinds of data about our visitors browser sizes. What is to be done with this data once we have it? If @beep has taught us anything, it’s that we can and should accomodate to browsers of any shape and size.

But still, having information is never a bad thing. Smarter men and women than me may see things I do not and think of reasonable actions to take based on this data.

Getting the Data

Since Google Analytics can’t currently help us, we’ll need to run some JavaScript on the page ourselves to get the data. jQuery makes it easy to measure sizes as well as make and Ajax call to POST the data to a script that can save it:

$.ajax({ type: "POST", url: "/savedata.php", data: { width : $(window).width(), height : $(window).height(), screen_width : screen.width, screen_height: screen.height } });

Now we just need that script savedata.php to be ready to accept and save that data. First we need a database, so here’s a simple structure for one:

I’m no MYSQL expert, but this is what exporting the structure from phpMyAdmin gave me:

CREATE TABLE `data` ( `id` int(11) NOT NULL auto_increment, `width` int(11) NOT NULL, `height` int(11) NOT NULL, `screen_width` int(11) NOT NULL, `screen_height` int(11) NOT NULL, KEY `id` (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=72141 DEFAULT CHARSET=utf8 AUTO_INCREMENT=72141 ;

And now my wicked primitive script for saving the POSTs:

<?php $dbhost = 'localhost'; $dbuser = 'db_user_name'; $dbpass = 'db_password'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'db_name'; mysql_select_db($dbname); $width = mysql_real_escape_string($_POST['width']); $height = mysql_real_escape_string($_POST['height']); $screen_width = mysql_real_escape_string($_POST['screen_width']); $screen_height = mysql_real_escape_string($_POST['screen_height']); $sql = "INSERT INTO data ( width, height, screen_width, screen_height) VALUES ($width, $height, $screen_width, $screen_height)"; if (!mysql_query($sql, $conn)) { die("Error:" . mysql_error()); } echo "1 Record Added"; mysql_close($conn); ?>

That’s what I did on CSS-Tricks for one day. If you’d like, here’s the complete data I collected as SQL.

Looking At The Results

Remember: ALL of this data was collected from css-tricks.com. So it’s a bunch of designer nerds, probably. It’s only relevant to this site and sites with very similar audiences.

First, the borin’ ol screen resolution data. I got this by querying 500 random samples of data and laying div’s of that size on top of each other with as light of gray as I could make. Incidently, its rgba(0,0,0,0.004) , because rgba(0,0,0,0.003) is pure white (weird).

Notice the rather hard lines. Monitors only come in so many sizes. Makes sense. Here’s what happens when we do the same thing with browser window sizes though:

Much more blurry. Also makes sense. Even as I write this my browser is at some very arbitrary sizing, probably about 80% of my screen resolution. Click those images above to see them bigger. You’ll notice that whatever visible hard edges there are in the browser size version, they are exactly 20px narrower than the screen size counterpart. Interesting.

If I tint the screen sizes red and the browser sizes green and put them on top of each other, this is what we get:

Notice on the outside edges the tint stays red. Not a lot of people who have extremely wide monitors have their browser window open that wide. I know I don’t. Let’s look at the stats for “full screen” browsers. How many people browser full screen, or with their browser window “maximized” so to speak. Well if you query only for entries where the window and the screen resolution are exactly the same, very few, less than 1%, but it get’s interesting:

Totally full screen 0.85% Within 50px of full screen 1.06% Within 100px of full screen 9.67% Within 200px of full screen 61.18%

So very few people browse full screen, but the majority of people browse pretty close to full screen. As speculation, it’s likely the Windows folks are the ones browsing full screen, as that’s much more natural behavior on that operating system. But now “full screen” is a big deal in OS X Lion, maybe that will start effecting this stuff.

If we put this stuff to a spread and use the entire data set, here’s one way to break it down:

Width Range Browser Window Screen Resolution 0px – 500px 1.13% 1.02% 501px – 800px 2.01% 1.06% 801px – 1000px 2.84% 0.07% 1001px – 1200px 14.91% 6.86% 1201px – 1400px 40.65% 35.57% 1401px – 1600px 17.38% 17.17% 1601px – 2000px 20.41% 34.34% 2000px+ 0.66% 3.91%

So where is mobile in all this? Despite reports of massive growth in mobile browsing, which I do not doubt, CSS Tricks has very little mobile traffic.

Let’s wrap it up with some quick hits:

The most popular screen resolution is 1680 x 1050 with almost 13% of visits having a monitor of that size.

Predictably, there is no one browser window size that is far above all others, but leading the pack is 1349 x 667 at 0.75% of visits.

The most popular screen resolution ratio is 16:10 with 46% of visits having that. Maybe because a lot of video is 16:9 and monitor makers wanted people to watch that but still have room for some OS chrome? 16:9 is next with 29%, 5:4 with 12%, and 4:3 with 8%.

All of those ratios are wider than tall. Turns out only 2% of visitors have screens that are taller than wide (or at least that report that way).

Actual browser windows also tend to be wider than tall, with only 3% of visits having dimensions that are taller than wide.

Average number of pixels per screen = 1,539,515

Average screen resolution = 1526 x 967

Average browser window size = 1366 x 784

Huge Thanks

To Jamie Bicknell of Rentedsmile Web Design for helping me wrassle together the MYSQL queries and PHP needed to do anything useful with the data.