Skip to content
doubtly

2 answers

Put the image and text in a container with position: relative, and place the text over it with position: absolute.

<style>
.container { position: relative; display: inline-block; }
.container img { width: 100%; display: block; }
.text {
  position: absolute;
  bottom: 10px; left: 15px;
  color: white; font-size: 24px;
}
.centered {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
</style>

<div class="container">
  <img src="snow.jpg" alt="Snow">
  <div class="text">Bottom left</div>
  <div class="centered">Middle</div>
</div>

The absolutely positioned text is placed relative to the container, so top, bottom, left and right put it at any corner; transform: translate(-50%,-50%) centres it. Without this CSS the text would simply appear below the image.

Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.