Web Hosting Talk







View Full Version : Problem with Css text-align!


kokillennium
12-24-2008, 02:39 PM
Hi all,
I've a very strange problem.
This footer is not aligned correctly to the right!
The xHTML is as follows:
<div id="footer">
<p>Copyrights reserved 2009</p>
</div>
The CSS is:
#footer {background-image:url('images/footer.gif');
width:800px;
text-align:right;
padding:0px;
background-repeat:repeat;
clear:both;}
Can any one help me and let me know why I can not have my copyrights reserved aligned correctly to the right?

killapix
12-24-2008, 02:46 PM
Should work.?
Need a little more info or code example.?
;)

kokillennium
12-24-2008, 02:51 PM
The code is very simple. It is just DIV and within it a <p> containing just this sentence above ^.
I need to align the sentence to the right using the mentioned Css code above^ with text-align property.
I do not know where is the problem :S

killapix
12-24-2008, 02:57 PM
Remove the
{background-image:url('images/footer.gif');
and replace with:
{background: #999;
also remove:
background-repeat:repeat;
clear:both;}
just as a test now you can see the div by the background and the text. You should have text-aligned right.?

kokillennium
12-24-2008, 02:58 PM
I fixed it. I had this code in the beginning of the CSS page:
/* Resetting every thing*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td
{
margin: 0;
padding: 0;
border: 0;
vertical-align: top;
text-align: left;
}
My question now. Does text-align: left; overrides the LAST sentence I wrote in the CSS file?
Why the footer did not override this ^?

killapix
12-24-2008, 03:05 PM
Because you are telling the browser to globally change all the css inside the html and body tag to text-align: left;. The text is aligned left by default..;) so you do not need that declaration. If you want to just make the css read:
*{
margin: 0;
padding: 0;
border: 0;
vertical-align: top;
}
That will be global..;)

kokillennium
12-25-2008, 03:52 AM
Thanks a lot man :) I got it now and I am really stupid. I forgot to use the *.
I do not why why I wrote all these html tags :D