<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
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.