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;
}
You have to use text-align: center;
, see this fiddle: http://jsfiddle.net/alp82/e3hgu/
Applying CSS text-align:center
to a block element centers its contents.
<div>
<img alt="" src="images/accessbg.jpg" align="left"></img>
<h2 align="center">Test</h2>
</div>
The above code will work for you.
精彩评论