---
title: Center an Element Horizontally Using the margin Property
---
## Center an Element Horizontally Using the margin Property

### Solution

```html
<style>
  div {
    background-color: blue;
    height: 100px;
    width: 100px;
    margin: auto;
  }
</style>
<div></div>
```
