HTML: Center & Centering

While many still rely on HTML to center things or make page elements centered in the middle of the page, it’s actually the job of CSS.

In HTML, you can center things such as texts or images by using the CENTER tag:

<center>This is in the center of the page.</center>

You can center not only texts but also images:

<center><img src="photo.jpg" alt="" /></center>

However this may seem simple and straightforward, it’s not the correct way to do this. Accordingly to web standards, centering should be produced by CSS:

<div style="text-align:center"><img src="photo.jpg" alt="" /></div>

Notice the style attribute of the div tag, text-align:center prescribes that the inner image is centered in the center of the browser window (page).

Scroll to Top