Learn how to place text blocks over an image.
Image Text Blocks
Nature
What a beautiful sunrise
Nature
What a beautiful sunrise
How To Place Text Blocks in Image
Step 1) Add HTML:
Example
html
<div class="container">
<img src="nature.jpg" alt="Norway"
style="width:100%;">
<div class="text-block">
<h4>Nature</h4>
<p>What a beautiful sunrise</p>
</div>
</div>
Step 2) Add CSS:
Example
css
/* Container holding the image and the text */
.container {
position: relative;
}
/* Bottom right text */
.text-block {
position: absolute;
bottom: 20px;
right: 20px;
background-color: black;
color: white;
padding-left: 20px;
padding-right: 20px;
}
To learn more about how to style images, read the CSS Images tutorial.
To learn more about CSS positoning, read the CSS Position tutorial.