You only need to calculate it for IE7 and older (and only if your content doesn't have fixed size). I suggest using HTML conditional comments to limit hack to old IEs that don't support CSS2. For all other browsers use this:
This is the perfect solution. It centers
of any size, and shrink-wraps it to size of its content.