Get your own website Result Size: 625 x 534
x
 
<!DOCTYPE html>
<html>
<head>
<style>
.container {
  position: relative;
}
.center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 18px;
}
img { 
  width: 100%;
  height: auto;
  opacity: 0.3;
}
</style>
</head>
<body>
<h2>Image Text</h2>
<p>Center text in image:</p>
<div class="container">
  <img src="img_5terre_wide.jpg" alt="Cinque Terre" width="1000" height="300">
  <div class="center">Centered</div>
</div>
</body>
<!-- Mirrored from www.w3schools.com/css/tryit.asp?filename=trycss_image_text_center2 by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 05 Sep 2022 14:30:28 GMT -->
</html>