Open this example in the interactive library
Source code
<style>
.demo {
width: 10rem;
margin-inline: auto;
}
</style>
<div class="demo">Centre a fixed-width box with margins</div>
Centre a fixed-width box with margins with native CSS. The preview includes a small shared demo stylesheet.
Open this example in the interactive library
<style>
.demo {
width: 10rem;
margin-inline: auto;
}
</style>
<div class="demo">Centre a fixed-width box with margins</div>