Microsoft Developer
Microsoft Developer

Reputation: 5459

Set text alignment in div tag

I have a div tag in which there is an image in left corner and in the middle of the div tag I want to write title of my web application. But I am not able to set text alignment in middle of the div tag. I tried text-align,valign properties with various values but could not set it. Can you please guide me how to to this.

CSS for my div tag is as below

    #head
    {
    background-color: #EEE685;
    overflow: auto;
    width: 100%;
    text-indent:10;
    text-align:justify; 
     }

Upvotes: 0

Views: 3423

Answers (3)

Alp
Alp

Reputation: 29739

You have to use text-align: center;, see this fiddle: http://jsfiddle.net/alp82/e3hgu/

Upvotes: 2

Ankit
Ankit

Reputation: 2753

<div>
    <img alt="" src="images/accessbg.jpg" align="left"></img>
    <h2 align="center">Test</h2>
</div>

The above code will work for you.

Upvotes: -2

DavidJCobb
DavidJCobb

Reputation: 1131

Applying CSS text-align:center to a block element centers its contents.

Upvotes: 2

Related Questions