I'm not quite sure what you mean by "center" (there are several definitions), but maybe this will do what you want:
<div class="myclass">Some text</div> .myclass { position: absolute; left: 50%; top: 50%; }
It does not matter whether it is text or an image - the browser simply considers it as the contents of a block.
Note that text-align: center; will center the elements horizontally inside its container.
source share