<main>
  	<h1>Am I centered yet?</h1>
	  <p>Center me, please!</p>
</main>
main {
    width: 18em;
    padding: 1em 1.5em;
    margin: 50vh auto 0;
    transform: translateY(-50%);
}
/* Base style */
main {
	padding: 1em 1.5em;
	box-sizing: border-box;
	background: #655;
	color: white;
	text-align: center;
}

h1 {
	margin: 0 0 .2em;
	font-size: 150%;
}

p {
	margin: 0;
}

body {
	background: #fb3;
	font: 100%/1.5 sans-serif;
}
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.