<div class="container"> <h1>Centred Title</h1></div>
<div class="container"> <img src="https://picsum.photos/id/1/200/200"></div>
.container {
  min-height: 40vh;
  border: 5px solid red;
  margin: 10px;
  position: relative;
}

.container > * {
  position: absolute;
  inset-area: center;
  margin: auto;
  border: 1px solid;
}


h1 {
  font-family: system-ui, sans-serif
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.