position: relativemoves the element to its original position (if there is an upper, lower, right or left setting), but at the same time saves the space that it originally had in the original (not moved) position that you see in your example. It does NOT resize the parent element as opposed to positioning static.
To solve the problem, you can make a tag aa inline-block, erase relative positioning and use margin-topinstead top. This will be completed by the parent:
.apple {
background: #ccc;
width: auto;
}
<div class="apple">
A for aplle
<br><a style="display: inline-block; margin-top:20px;">B for Ball</a>
</div>
Run codeHide result source
share