By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,879 Members | 1,809 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,879 IT Pros & Developers. It's quick & easy.

Simple CSS question about relative sizes

P: n/a
What is the property that defines the difference between the line-hight
and the font-size?

E.g.:

I have two <div>'s with no properties set at all.

I then give the second div a left margin and a negative top margin to
place it adjacent to the first div.

Without setting the line height nor the font size, I figured the only
way to line them up is to use em sizes, however if I set the second div's
top margin to -1em, it doesn't line up ... it needs to be -1.2em. What
property accounts for that extra 0.2em and how do I control it separately?

I thought it might be padding, but I set padding (and all margins except
the ones I need) to zero, without effect.

TIA,

-
[H]omer
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"[H]omer" <uc*@ftc.gov> wrote:
What is the property that defines the difference between the
line-hight and the font-size?
There is no such property. You can, however, set e.g.
line-height: 1.3em
or
line-height: 130%
or
line-height: 1.3
which have the same effect on the element but have different behavior in
inheritance.

The initial value of line-height is browser-dependent. The CSS
specifications are very confused in their recommendations on this value.
I have two <div>'s with no properties set at all.

I then give the second div a left margin and a negative top margin to
place it adjacent to the first div.
Exactly what are you trying to achieve and how? URL?
Without setting the line height nor the font size, I figured the only
way to line them up is to use em sizes, however if I set the second
div's top margin to -1em, it doesn't line up ... it needs to be
-1.2em. What property accounts for that extra 0.2em and how do I
control it separately?


Sounds very confused. It is generally a bad idea to try to make text
lines touch each other. The 0.2em you're seeing is probably caused by an
initial value of 1.2 for line-height in the browser.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Jul 20 '05 #2

P: n/a
On Sat, 08 May 2004 18:07:10 +0000, Jukka K. Korpela wrote:
"[H]omer" <uc*@ftc.gov> wrote:
What is the property that defines the difference between the
line-hight and the font-size?
There is no such property.
Thought so.
The initial value of line-height is browser-dependent.
So would it be considered bad form to always set the line-height property
of the page, to ensure consistency?
Exactly what are you trying to achieve and how? URL?
Basically just trying to accurately align elements on a page, but do it
fluidly. Here's the (very rough) draft:

http://www.genesis-x.nildram.co.uk/i...aft-layout.png
Without setting the line height nor the font size, I figured the only
way to line them up is to use em sizes

Sounds very confused.
Well sure, I'm still getting to grips with this stuff. I'm just trying to
figure out how to accurately place elements without using absolute
positioning, whilst remaining fluid, and keeping it neat no matter how
small the browser window. I don't want to be designating literal values
for height etc., if I can get away with it.
It is generally a bad idea to try to make text lines touch each other.
Oh sure, I appreciate that. So long as I know the values concerned, I can
line things up accurately.
The 0.2em you're seeing is probably caused by an initial value of 1.2
for line-height in the browser.


Yup. I just set the page property for line-height to 1em, and everything
magically lined up. Of course now the text touches, so I'll set it back to
1.2em and use multiples of that value for positioning ... now I know what
(and why) it is.

Thanks,

-
[H]omer

Jul 20 '05 #3

P: n/a
On Sat, 08 May 2004 19:43:04 +0100, [H]omer <uc*@ftc.gov> wrote:

So would it be considered bad form to always set the line-height property
of the page, to ensure consistency?


Hmm. I can't say it's bad form, but I generally don't even touch
line-height unless I really need to. Seems to me default line height is
normally acceptable unless you're doing something rash.
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.