How TO - Text Blocks Over Image
Learn how to place text blocks over an image.
Image Text Blocks
How To Place Text Blocks in Image
Step 1) Add HTML:
Example
<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
/* 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;
}
Try it Yourself »
To learn more about how to style images, read our CSS Images tutorial.
To learn more about CSS positoning, read our CSS Position tutorial.
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.