Previous Message
Next Message

Baseline Border

Sent by Eric A. Meyer on 9 January 2004 16:04


At 16:45 +0000 1/9/04, [EMAIL-REMOVED] wrote:

>Is it possible to get a border to align to the baseline of a text item?

    Yes, but only by monkeying with the line-height, which it would 
seem you're already doing.

>So, my questions are:
>1. Is there a method to reliably get a border to align to a baseline?

    No, but you can get close.  For those who are wondering how, pick 
a common font, like Times or Verdana or Arial for your header.  For 
example:

    h1 {font-family: Arial, sans-serif; border-bottom: 1px solid;}

Now add in a line-height value that stands a chance of being close to 
what you want.  I usually start at 0.8em.

    h1 {font-family: Arial, sans-serif; border-bottom: 1px solid;
      line-height: 0.8em;}

Then adjust the line-height up or down by 0.05em until you get the 
effect you want.
    The resulting effect will not precisely replicate in all browsers, 
but it will be very close.  However, that's not precisely your 
problem, it would seem-- what you're encountering is a problem with 
getting different text sizes to align their baselines to the border. 
That's much trickier.  I'd have to experiment just to get close to an 
answer, and suspect that whatever I devised would get broken by 
IE/Win.

>2. In the case of font substitution, will font-size-adjust provide any help?

    It would if it were supported, but realistically, no.  (Moz/Win 
supports it, I think, but that might be it.)

-- 
Eric A. Meyer (http://www.meyerweb.com/eric/), List Chaperone
"CSS is much too interesting and elegant to be not taken seriously."
   -- Martina Kosloff (http://www.mako4css.com/)
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread: