# Understanding Absolute position better

**URL:** <https://forum.freecodecamp.org/t/understanding-absolute-position-better/105062>\
**Category:** General\
**Created:** [April 11, 2017, 4:35pm UTC](https://forum.freecodecamp.org/t/understanding-absolute-position-better/105062 "2017-04-11T16:35:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![carpben](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/carpben/32/31512_2.png) [@carpben](https://forum.freecodecamp.org/u/carpben)\
**Post date:** [April 11, 2017, 4:35pm UTC](https://forum.freecodecamp.org/t/understanding-absolute-position-better/105062/1 "2017-04-11T16:35:11Z")

</div>

Hi everyone,  
In the FCC Beta version =\> Applied visual design, the code in the snippet below is given to us. The .heart div has this positioning:

```auto
position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;

```

Since there is no other item which is positioned, it is positioned relative to the body element. My question is: Why is it showing in the center of the screen? Is it because all sides “pull” the element to the same extent? Is it a good practice for centering elements?

 ![](https://global.discourse-cdn.com/freecodecamp/original/3X/d/0/d0b196905262d18085ae8e31c158a07ef1f14141.png)

---

<div class="post-metadata">

**Author:** ![Cowwy](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/cowwy/32/158666_2.png) [@Cowwy](https://forum.freecodecamp.org/u/Cowwy)\
**Post date:** [April 11, 2017, 5:29pm UTC](https://forum.freecodecamp.org/t/understanding-absolute-position-better/105062/2 "2017-04-11T17:29:54Z")

</div>

Wow, this is a really good question 😃  
I didn’t know it at first until I read further. Someone asked the same question 2 years ago on StackOverflow apparently. It all made sense after reading the definition of what it is actually doing.

> <https://stackoverflow.com/questions/28080910/what-does-top-0-left-0-bottom-0-right-0-mean>

Essentially, the left, right, top and bottom is setting a new boundary for the content to be center.  
Here is a codepen of what it meant. You gonna need to look at it in full view.  
[Perfect Centering](http://codepen.io/Cowwy/pen/LyPQOv?editors=1100)

---

<div class="post-metadata">

**Author:** ![carpben](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/carpben/32/31512_2.png) [@carpben](https://forum.freecodecamp.org/u/carpben)\
**Post date:** [April 12, 2017, 3:49am UTC](https://forum.freecodecamp.org/t/understanding-absolute-position-better/105062/3 "2017-04-12T03:49:31Z")

</div>

Thank you! After experimenting with your pen I would like to add this - As you said the ‘top’, ‘right’, ‘bottom’ and ‘left’ properties set the boundaries, but it is the margin: auto which centers the element within the boundaries, both horizontally and vertically.

---

<div class="post-metadata">

**Author:** ![mirkoacimovic](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/mirkoacimovic/32/45427_2.png) [@mirkoacimovic](https://forum.freecodecamp.org/u/mirkoacimovic)\
**Post date:** [April 14, 2017, 6:59am UTC](https://forum.freecodecamp.org/t/understanding-absolute-position-better/105062/4 "2017-04-14T06:59:19Z")

</div>

Yes, when you say margin:auto it will center your content, so that its it. 🙂

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 9:35am UTC](https://forum.freecodecamp.org/t/understanding-absolute-position-better/105062/5 "2021-01-17T09:35:43Z")

</div>

Closed on January 17, 2021, 9:35am UTC


