Home › CSS Tutorial › CSS margins
CSS margins
Space outside an element.
Margin shorthand goes top, right, bottom, left. margin:0 auto centers a block with a set width. Vertical margins can collapse.
Example code
<style>
div{width:200px;background:#cde;margin:20px auto;padding:10px}
</style>
<div>Centered</div>