Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Centering an object in WordPress

I have a blog on wordpress and I need to center an object. What is the easiest way?

like image 681
Adrian D'Urso Avatar asked Apr 08 '26 00:04

Adrian D'Urso


1 Answers

You cannot do layout with PHP, it is for programming logic. To do layout you use CSS and HTML. To center text you can use the text-align tag that jdhartley showed above. To center a block like a table or div you use the following CSS:

<style>
.centered {width:950px; margin-left:auto; margin-right:auto;}
</style>

<div class="centered">Bunch of stuff to be centered</div>

The width can be anything, but you do have to set it. It can be a percent like 90% or a pixel width.

like image 132
Steve Massing Avatar answered Apr 10 '26 13:04

Steve Massing