<html> <style> div.rect { width: 10px; height: 10px; display: inline-block } </style> <body> <div style="width: 100px; border: 1px solid blue"> <div class="rect" style="background: lime"></div ><div class="rect" style="background: blue; margin-left: 20px"></div> </div> <div style="width: 10px; height: 100px; border: 1px solid purple"> <div class="rect" style="background: lime"></div> <div class="rect" style="background: purple; margin-top: 20px"></div> </div> </body> </html>