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:
<div style="float: left; margin: 2%; width: 40%;"> code</div>
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.