<section>
  <div><h1>My x-y centred div</div>
</section>
body,
html {
  height: 100%;
  margin: 0;
  min-height: 100vh;
}

section { display: flex; align-items: center; justify-content: center; height: 100%; width: 100%; }
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.