Forum Moderators: not2easy

Message Too Old, No Replies

Text link won't center?

         

keyplyr

8:51 pm on Apr 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Text link won't center in external CSS:

div.special a {
background:transparent;
color:#699;
font:bold 15px verdana,arial,sans-serif;
text-align:center;
}
<div class="special"><a href="http://blah.com">Text link</a></div>

But it will using inline:

<div class="special" style="text-align:center;">"><a href="http://blah.com">Text link</a></div>

What's Up? Thanks.

<edit to clarify question>

[edited by: keyplyr at 9:57 pm (utc) on April 1, 2004]

grahamstewart

8:59 pm on Apr 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your problem is the selector.

div.special a {
text-align:center;
}

..is the equivalent to writing..

<div class="special">
<a style="text-align:center;">Text link</a>
</div>

but you want all text in the div to be centered so you actually want..

div.special {
text-align:center;
}

keyplyr

9:48 pm on Apr 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



When I do that, I loose the color.

Elijah

10:11 pm on Apr 1, 2004 (gmt 0)

10+ Year Member



I think this is what you want:

div.special {
text-align:center;
}
div.special a {
background:transparent;
color:#699;
font:bold 15px verdana,arial,sans-serif;
}
<div class="special"><a href="http://blah.com">Text link</a></div>

keyplyr

12:43 am on Apr 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




Yes, thanks Elijah. I guess that's what grahamstewart was also telling me.

You'll excuse me - I'm getting old. Sometimes I open an editor and can't remember what I was going to do - LOL