Skip to main content

Chris Coyier

Founder, writer, designer, spam-deleter, email personality


SXSW + HTML5 Forms


Wolf in Sheep’s Clothing

Roger Johansson has a neat quick-tip style article on centering page content both vertically and horizontally by making the html element display: table; and the body element display: table-cell; with vertical-align: middle;. See the full code to make it happen in the article.

I'm down with that. Works in all modern browsers and IE 8 plus.

I disagree on this though:

I’ve seen people saying that using these CSS properties to create “CSS tables” is no better than using

Read article

Display Browser and Version

This is jQuery specific, and contains a bit of a hack/fix for dealing with Chrome. This works between jQuery 1.5.1 and jQuery 1.8.3. It's gone in jQuery 1.9. Presumably because it was used too improperly too frequently and it was hurting the web. Better to feature detect when possible.

var userAgent = navigator.userAgent.toLowerCase(),
    browser   = '',
    version   = 0;

$ = /chrome/.test(navigator.userAgent.toLowerCase());

// Is this a version of IE?
if ($.browser.msie) {
  userAgent = $.browser.version;
  userAgent = userAgent.substring(0,userAgent.indexOf('.'));	
  version = 
Read article