HTML and CSS

Image Caption

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.6);
  color: rgba(255, 255, 255, 0.4);
  padding: 1rem;
  width: 100%;
  font-family: 'Oswald', sans-serif;
  font-size: 2.4em;
  line-height: 1.1em;
  text-transform: uppercase;
  text-align: center;
}