Skip to content

How to put an item at the bottom of its container using CSS

New Course Coming Soon:

Get Really Good at Git

Find out how to stick an item at the bottom of its container using CSS

It’s a rather common thing to do, and I had to do it recently.

I was blindly assigning bottom: 0 to an element which I wanted to stick to the bottom of its parent.

Turns out I was forgetting 2 things: setting position: absolute on that element, and adding position: relative on the parent.

Example:

<div class="container-element">
  ...
  <div class="element-to-stick-to-bottom">
    ...
  </div>
</div>
.element-to-stick-to-bottom {
  position: absolute;
  bottom: 0;
}

.container-element {
  position: relative;
}
Are you intimidated by Git? Can’t figure out merge vs rebase? Are you afraid of screwing up something any time you have to do something in Git? Do you rely on ChatGPT or random people’s answer on StackOverflow to fix your problems? Your coworkers are tired of explaining Git to you all the time? Git is something we all need to use, but few of us really master it. I created this course to improve your Git (and GitHub) knowledge at a radical level. A course that helps you feel less frustrated with Git. Launching Summer 2024. Join the waiting list!
→ Get my CSS Handbook
→ Read my CSS Tutorial on The Valley of Code

Here is how can I help you: