View Full Version : Giving DIVs Different Attributes


Vanessa023
12-06-2010, 02:33 AM
How do I have a DIV float in the centre of my page and have the text aligned within that DIV as left or justified?

I tried coding it into the CSS like so:
div.content { float:center; width:300px; text-align:left; }

And calling for it on my page:
<div class="content">
yada yada yada
</div>

One code seems to override the other... Is there a way to do this or am I dreaming? I'm sure if there is, it's very simple and I am very... lost, lol.

Thanks,
Vanessa

PS. It should also be noted that I am working in WordPress =)

AndrisE
12-09-2010, 10:17 AM
There is no float value named "center".

Most common way to center block (DIV) is to set it's width and define margin:0 auto; What will center your DIV in all modern browsers and IE6+.

<div id="centered">text text text</div>

and CSS:

#centered {
width: 500px;
margin: 0 auto;
text-align: left; /* you can set anything there */
}

Vanessa023
12-10-2010, 04:45 AM
thank you very much! worked like a charm =) site looks perfect

Vanessa

xavierhibbins
12-14-2010, 07:37 AM
i m agreed with AndrisE.......
any other HTML and CSS Help let me know

Vanessa023
01-11-2011, 02:33 AM
Hello Again Friends...

Now the client wants the text aligned to the left and I'm having trouble accomplishing this. Either the div stays aligned in the centre or the attribute isn't applied. Help please!!!!

Vanessa