tags:

views:

82

answers:

3

I've to align some text in the center of the page with div tag.

A: 

You could set the style of the div to be:

<div style="width: 250px; margin-left:auto; margin-right:auto;">TEXT</div>

You can also place that style in a CSS class and set the class of the div to whatever you named it.

EDIT: If you include a width for the div, it centers...

kchau
@kchau: is that really centering it ? I don't think so ...
RageZ
@RageZ: My CSS style is exactly like meder's... I just forgot the width.
kchau
+4  A: 
div#foo { text-align:center; }

to align the text within the div or

div#foo { width:100px; margin:0 auto; }

to make the div 100px width and horizontally center it.

meder
A: 

You can try <div align="center">...</div>

Laserson
That only centers the text. If OP specifies a width to the <div> then the div will still display blocked to the left.
kchau