Centering An Image Or Text Within A Div

This post explains how to center an image or text in HTML using CSS. The code example is available on GitHub in the Center-Image-Text-Div directory.

Centering An Image Vertically And Horizontally Within A Div
The method described here requires to know the size of the image. The HTML is the following:

<div id="myDiv">
<img id="myImg" src="SomeImg.jpg">
</div>

The CSS is the following:

#


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *