Edit: this post has been somewhat superseded by new features added to to the Google Adsense responsive ad unit .
In July, Google Adsense finally announced some initial support for responsive web sites. Two problems with the Adsense solution are clear:
- The ad sizes are controlled via media queries on the viewport size when what is really needed is ad sizes based on the space available in the enclosing HTML container.
- There's no mechanism to not display an ad. Typically on a smartphone you are not going to want to display as many ads as you will on a desktop or tablet for instance.
You also need to add the following code at the bottom of your page for the above example to work.
<script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
The above code is difficult to maintain and impractical if you're inserting the code by hand, but if the code is generated from some server side function then that's not an issue.