<style> .test { width: 400px; height: 200px; background: green; } .rectangle { width: 200px; height: 100px; background: blue; } .test-center1 { margin: 0 auto; } .test-center3 { text-align: center; } </style> <div class="test"> <div class="rectangle test-center1"> test1 </div> </div> <br /> <div class="test"> <div class="rectangle" align="center"> test2 </div> </div> <br /> <div class="test"> <div class="rectangle test-center3"> test3 </div> </div>