codegurukool.com · Free coding tutorials & online compiler

Home › CSS Tutorial › Position

Position

Place elements exactly where you need them.

relative offsets from the normal spot and creates a reference. absolute positions inside the nearest positioned parent. sticky sticks while scrolling.

Example code

<style>
  .box{position:relative;height:140px;background:#eee}
  .tag{position:absolute;top:10px;right:10px;background:crimson;color:#fff;padding:4px 8px}
</style>
<div class="box">Parent<span class="tag">New</span></div>

Run this code in the online editor

← Units and variablesCSS Grid →