Logo Luan Morina
CSS image caption demonstration
We live as we dream: alone

What is a CSS image caption?

A CSS image caption is a descriptive text that accompanies an image, providing context or additional information. It’s typically displayed below or above the image. Here's an example:

HTML

<div class="demo-content">
<div class="demo-caption">We live as we dream - alone</div> 
</div>

CSS

.demo-content {
height: 40vh;
background-image: url("demo-bg.jpg");
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}

.demo-caption {
background-color: rgba(85, 108, 66, 0.60);
color: rgba(255, 255, 255, 0.60);
padding: 1rem;
width: 100%;
font-family: 'Oswald', sans-serif;
font-size: 2.4em;
line-height: 1.1em;
text-transform: uppercase;
text-align: center;
border-top: 4px solid rgba(255, 255, 255, 0.6);
border-bottom: 4px solid rgba(255, 255, 255, 0.6);
}	
   CSS Captions