# Relative Positioning Issues

**URL:** https://forum.kirupa.com/t/relative-positioning-issues/646182
**Category:** Uncategorized
**Created:** [February 16, 2021, 8:58pm UTC](https://forum.kirupa.com/t/relative-positioning-issues/646182 "2021-02-16T20:58:19Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![John\_Stern](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/john_stern/32/12050_2.png) [@John\_Stern](https://forum.kirupa.com/u/John_Stern)
#### Post date: [February 16, 2021, 8:58pm UTC](https://forum.kirupa.com/t/relative-positioning-issues/646182/1 "2021-02-16T20:58:19Z")

</div>

[**https://www.freecodecamp.org/news/learn-the-basics-the-css-position-property/**](https://www.freecodecamp.org/news/learn-the-basics-the-css-position-property/)

\<\< We will also give its parent element a relative position so that it does not get positioned relative to the element. \>\>

```
.parent-element {

position: relative;

height: 100px;

padding: 10px;

background-color: #81adc8;

}

```

I’m not quite certain that I understand what is going on here. I am guessing that the parent element is being positioned relative to the html element - correct? And the sole reason for using this line - position: relative - is so that the

position: absolute property of .main-element is connected to the parent element - correct?

---

<div class="post-metadata">

### Author: ![ariful](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@ariful](https://forum.kirupa.com/u/ariful)
#### Post date: [February 17, 2021, 2:59am UTC](https://forum.kirupa.com/t/relative-positioning-issues/646182/2 "2021-02-17T02:59:12Z")

</div>

> [@John\_Stern](#):
>
> `position: relative;`

Positive relative work with at least one property such as: left, right, top and bottom.  
.parent-element {  
position: relative;  
height: 100px;  
padding: 10px;  
background-color: #81adc8;  
left: 50px;  
top:50px;  
}  
position: absolute property of .main-element is connected to the parent element - correct?  
Yes, it is correct.

---

<div class="post-metadata">

### Author: ![John\_Stern](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/john_stern/32/12050_2.png) [@John\_Stern](https://forum.kirupa.com/u/John_Stern)
#### Post date: [February 17, 2021, 4:14pm UTC](https://forum.kirupa.com/t/relative-positioning-issues/646182/3 "2021-02-17T16:14:26Z")

</div>

Thanks for setting me straight on that.

---

<div class="post-metadata">

### Author: ![steve.mills](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/steve.mills/32/14961_2.png) [@steve.mills](https://forum.kirupa.com/u/steve.mills)
#### Post date: [February 18, 2021, 7:01am UTC](https://forum.kirupa.com/t/relative-positioning-issues/646182/4 "2021-02-18T07:01:07Z")

</div>

I put relative on everything by default.  
This allows you to set the z-index on any element it also allows position absolute to work (I use before and after psuedo elements with position absolute a lot).
