Previous Message
Next Message

What's the proper way to vertically center an element within its parent?

Sent by Ed Seehouse on 3 March 2007 20:08


On 3/2/07, Chris Chen [EMAIL-REMOVED]> wrote:

> I can't seem to be able to style <a> inside <span> to make it centered
> *vertically* inside <span>.

Both of these elements are inline so the only things you can adjust
are the line height and the font size.  If you must for some reason
adjust them vertically then you should be using block elements
instead, or in the last resort apply a display: block; to the elements
in question so you can use the block element CSS rules.  Not a good
idea really, since it wrecks the semantics of your code.

> <span class="span_link"><a href="http://www.msn.com" >Hello</a></span>

Whatever reason is the span there for?  There's nothing you can do
with that construction that you can't do with just the link.  e.g.

> <a class="span_link" href="http://www.msn.com" >Hello</a>

If it is part of a menu it belongs in a list, however.

Ed Seedhouse
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
IE7 information -- http://css-discuss.incutio.com/?page=IE7
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread:

Possibly related: