# Thread: line-height in pixels and font-size in percent.. correct?

1. ## line-height in pixels and font-size in percent.. correct?

Hi

Is that correct to have something like this?

Code:
``` line-height: 17px;
font-size: 75%;```
Should I have the line height in percent as well? What would be equal to 17px in percent?

2. I don't believe it will matter. I've done line height it pt (forgot what it stands for) and my font size in pixels.

3. If your font size is going to be set in percentages, set your line-height to a percentage as well for consistency. If a user bumps their text size up to something past 17px tall, your lines will run into each other.

4. Yes as Vinnie says if the line-height is fixed in pixels and the font is percent then the font will grow but the line-height will stay the same and the font may grow out of the line.

If you use percent or ems for line-height then they stay proportional to each other as the text is resized.

If you have the font-size int the body set to 12px and your p tag set to 75% then that will be 9px high. So you can work out from there how much bigger 17px line height would need to be (about 1.9ems if my maths is correct )

Paul

5. Originally Posted by Paul O'B
If you have the font-size int the body set to 12px and your p tag set to 75% then that will be 9px high. So you can work out from there how much bigger 17px line height would need to be (about 1.9ems if my maths is correct )
It's actually 1.8888888888888888888..... ems, but that's just splitting hairs

6. lol - but I worked it out in my head not on a calculator

7. Originally Posted by Paul O'B
lol - but I worked it out in my head not on a calculator
I did too. Any number divided by 9 will just repeat itself. Example:

2/9 = .2222222222222

Ex-math major here

8. Any number divided by 9 will just repeat itself

9. Paul: well it is equal to 1.00000... if u think about it

10. Originally Posted by Paul O'B
The remainder repeats itself, smarty pants

11. btw... can anyone tell what is the math for translating pixels into em?

now, what if I let the margin in px? Is that a problem (in terms of consitancy):
Code:
```body {
background: #fff;
color: #000;
margin: 10px;
line-height: 1.9em;
font-size: 0.75em;
font-family:Verdana, Arial, Helvetica, sans-serif;
text-align: center;/* center for ie5*/
}```
and also.. one last thing... when the text appears in the context of a form, such as in the above code. When setting the size of the text to something quite big (using my browser) I realized that the input fields and the text don't line up nicely... why is that? can I avoid that?
Code:
```<fieldset>

<p>
</p>
<p>
</p>
<p></p>
<p>
</p>

</form>

</fieldset>```

12. There's no real way to directly translate pixels to ems. Ems are based on the user's default text setting in their browser. Most browsers' default size is 14px unless the user decides to change it, but some browsers have 16px as the default. If you need to use pixels, then use pixels. Otherwise, if you have more flexibility in your layout use percentages or ems.

13. So using % or ems is quite the same is that it?
In this case I think I will feel more comfortable with ems...

what about the 'resizing text/forms' issue?

14. Originally Posted by duuudie
So using % or ems is quite the same is that it?
In this case I think I will feel more comfortable with ems...
Use what you're comfortable with. They pretty much do the same thing.
Originally Posted by duuudie
what about the 'resizing text/forms' issue?
What do you mean? A user will resize text if they need to (I tend to do it on small-text sites myself; my eyesight isn't so great if I don't have my contact lenses in). Make sure your layout can accommodate at least a few different text sizes if possible. .

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•