Wednesday, 23rd June 2010
The new frontier for learning Java

Css Centering things

From WikiJava

Jump to: navigation, search


This page shows few examples of how to center several entities in an HTML page using CSS.

Contents

the article

How to position objects in css vertically and horizontally is something I always forget, in the following examples it's shown how to do the trick.

centering a block

<div style="display: block;margin-left: auto; margin-right: auto ">the div</div>

centering text

p { text-align: center }

centering vertically

div.box {
    vertical-align: middle }
,


Comments from the users

To be notified via mail on the updates of this discussion you can login and click on watch at the top of the page


Title (required):

Website:

Comment: