---
id: 587d78a3367417b2b2512ad0
title: Center an Element Horizontally Using the margin Property
challengeType: 0
videoUrl: 'https://scrimba.com/c/cyLJqU4'
forumTopicId: 301043
---
## Description
Another positioning technique is to center a block element horizontally. One way to do this is to set its margin to a value of auto.
This method works for images, too. Images are inline elements by default, but can be changed to block elements when you set the display property to block.
## Instructions
Center the div on the page by adding a margin property with a value of auto.
## Tests
```yml
tests:
- text: The div should have a margin set to auto.
testString: assert(code.match(/margin:\s*?auto;/g));
```
## Challenge Seed
## Solution