I want to put two adsense boxes before my content in such a way that both boxes appear together. Like on this page.
| SitePoint Sponsor |

I want to put two adsense boxes before my content in such a way that both boxes appear together. Like on this page.


They haven't done that very well. Firstly, they use outdated code to make that happen, and I don't see the point, as it just repeats the ads!
Anyhow, if you really want to do this, create two divs, give them a width a bit less than half the width of the content area, set them to float: left; or display: inline-block; and then paste the Google code inside each of them.



It's better to put the styles in your external style sheet, but I'll put them inline here for demo porpoises. You need to give the boxes a width or floating won't do anything. Ideally, we should see your page (or some demo code) to know what circumstances you're working within (fixed width wrapper? etc.), but here's a possible way to go:
If your content area has a fixed width, you could change the width and margins to pixels, but mixing pixels and % is a bit hit and miss.Code:<div style="float: left; margin: 2%; width: 40%;"> code</div>



OK, try changing the styles on that container div to:
and then duplicate it so that there are two.Code:<div style="float: left; margin: 3px 10px 3px 3px; width: 330px;"> </div>



Bookmarks