views:

845

answers:

6

I don't see this question answered anywhere else here.

Here's the code:

<div class="copyright">
<h2 class="copyright unselectable" onselectstart="return false">
&copy;&nbsp;2009&nbsp;-&nbsp;<?=date("Y") ?>&nbsp;<?=PROJECT_NAME?>
</h2>
</div>

It's aligning right in IE but not FF or Safari. It seems to not be taking into account the spacing for the echoed text?

Thanks!

Edit: Adding css that is there:

div.copyright h2.copyright{
  font-family:Verdana, Arial, Helvetica, sans-serif;
  font-size:13px;
  color:#000000;
  font-weight:bold;
  text-align:center;
}

Second Edit: Well I just hard coded the text with the same results...so it's not the echo issue like I though. I'll have to look deeper at this.

A: 

Just add a style attribute to H2:

<h2 class="copyright unselectable" onselectstart="return false" style="text-align:center">
&copy;&nbsp;2009&nbsp;-&nbsp;<?=date("Y") ?>&nbsp;<?=PROJECT_NAME?>
</h2>

Or better, add that property to your CSS rule for .copyright:

.copyright {
    text-align: center;
    /* … */
}
Gumbo
hi-sorry for the confusion. That is already in the CSS. For some reason the echo text seems to not be taken into consideration
Joel
A: 

The code sample that you posted seems to be aligning correctly to the center in both Firefox and Safari (on a Mac). The correct CSS to use is text-align: center;. What is the HTML and the associated CSS surrounding that piece of code? There could be something else causing the text to not look centered.

NerdStarGamer
A: 

OK. I fixed it-and the answer is too stupid to post here...

...haha The box above the copyright area was not centering right in ff and safari but was right in IE. :-D

Joel
A: 

You can try

div.copyright h2.copyright{
  font-family:Verdana, Arial, Helvetica, sans-serif;
  font-size:13px;
  color:#000000;
  margin:0 auto;
  font-weight:bold;
  text-align:center;
}
c0mrade
A: 

Try giving the h2 a width. If you're using a reset stylesheet it's default styling may have been over ridden. If the h2 isn't wider than it's text, then it will appear that the text isn't being centered.

Rowno
A: 

Thanks for the info guys. Needed this too.

Jordan