bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Pixels vs EM & Vertical Rhythm

Open ifesdjeen opened this issue 14 years ago • 71 comments

Hi,

Would you be interested in getting rid of Pixel measurements and taking a more flexible approach, using EM?

For things like, for example Legend size, paddings for headings, alert blocks, buttons nav tabs. These things are more likely to be relative than absolute.

Also, sizes of input controls, sizes or labels and many more things. All of them rely heavily on the base font size, and it will such an improvement to have all those things in a relative measurements (em) rather than absolute (px).

ifesdjeen avatar Feb 13 '12 13:02 ifesdjeen

Nope, no em units. They complicate simple values and scales unnecessarily and for little reward. Pixels are fine as browsers just zoom the page without any problem.

mdo avatar Feb 13 '12 16:02 mdo

@markdotto is it possible to get a response from a technical rather than designer person?

"Complicate simple values" is simply not true. Things like 60px, 40px don't really let you do nice vertical rhythmical composition.

It's not about zoom. It's more about other people using a different base font size, therefore requiring having different margins, paddings and sizes of different elements.

ifesdjeen avatar Feb 13 '12 16:02 ifesdjeen

Actually I'm more than happy to accept @markdotto's expertise here. What I'd like is some source to reference so I can understand why every design article on typography and vertical rhythm I've read on this is wrong. I assume it's because something has changed, but I'd like to dig in a bit before either committing to an entirely pixel based typography or spending time overriding all of bootstrap's values with an em based one.

chrisnicola avatar Mar 26 '12 23:03 chrisnicola

As far as I known pixel doesn't works when someone (maybe with vision problems) change the default browser font size. In my test seems that bootstrap doesn't work in this case. I am right?

thanks

davideicardi avatar Jul 18 '12 10:07 davideicardi

Can we at least have support for em based settings? Right now if I set $baseFontSize to 1em everything explodes. Thanks

DrummerHead avatar Aug 23 '12 19:08 DrummerHead

+1 for an explanation or at least support for em based settings.

opensource21 avatar Sep 10 '12 17:09 opensource21

+1 I would love to hear a detailed explanation. Browser zoom is not equivalent to resizing text for someone who is vision-impaired.

Undistraction avatar Oct 23 '12 13:10 Undistraction

davideicardi is correct, sizes set in pixels are not influenced by the base font size set in most browsers. The problem with px is not only an a11y thing, users change the base font size up or down if they have high or low density screens. Zoom is a great thing, but there is a good reason why browsers have a base font size setting.

martent avatar Oct 24 '12 19:10 martent

+1 I also would like to hear a clear explanation or support for an em based setting (at least for headers and possibly padding ). Other than that you guys are doing a great job! That needs to be said too, so keep up the good work.

RonaldV avatar Oct 25 '12 10:10 RonaldV

If anything em removes complexity.

Having px line-heights instead of relative ones are also another weird thing in boostrap.

Charuru avatar Oct 26 '12 16:10 Charuru

@markdotto Setting sizes in pixels is not responsive at all. Not responsive to the device and it's settings and not to user preferences. After all, responsive web design is not just about letting boxes move around and change size depending on the width and orientation of the device.

martent avatar Oct 27 '12 11:10 martent

I totally agree with @martent. sizes based on px are not responsive. The only but that I see, is that mostly of the people doesn't know how to work with em sizes properly and that's the main reason from others to reject it.

luishdez avatar Nov 02 '12 11:11 luishdez

@markdotto Would be nice to know if this is on the roadmap? Or even being discussed?

Undistraction avatar Nov 02 '12 14:11 Undistraction

I agree with all of you who want em instead of px. I can accept px in some places like borders where you may just want something thin. But an em almost works like an variable. If i want my site more readable i can just set my font-size in body and everything works with it (i.e size of buttons and line heights will change to). I cud use % instead but thats more complex imo.

alex-ross avatar Nov 04 '12 14:11 alex-ross

+1 for more information regarding this.

livingincircuits avatar Nov 07 '12 13:11 livingincircuits

+1 for explanation on preference for px vs ems or even rems I get the point that not alot of people do change their browser base font size. However, what is the benefit of using px?

ghost avatar Nov 15 '12 11:11 ghost

I'd love to be able to use ems rather than pixels too. An advantage of using ems is that you can adjust the base font size within a media query.

If, for example, you use large type on larger displays (to achieve a comfortable measure), you may find that on smaller displays your measure is far too short. Shrinking the base font size within a media query will cause type and line-height (and anything else you have set with ems) to reduce in the correct proportions for all elements.

Edit: I think this is pretty much what @izepax is saying, but through using media queries.

austinbirch avatar Nov 16 '12 22:11 austinbirch

not a complete answer but found this https://github.com/twitter/bootstrap/issues/373

danielmahon avatar Nov 20 '12 00:11 danielmahon

That's the same answer as here. But a lot of people clearly disagree. Using em is really important for manageable themes, I'm really surprised that there are some people who have taken the side of px.

Charuru avatar Nov 20 '12 01:11 Charuru

Okay, so here's a bit of a background on the decisions of yesteryear and plans for moving forward.

  • Pixels provide absolute control and consistent rendering across every browser.
  • Designers still mostly think and operate in pixels.
  • Browsers scale up entire pages these days, so it's not an issue with type scaling or anything.
  • Nesting ems historically has been a pain and can require extra math for figure computed/intended pixel values.
  • Mixing units of measurements is ugly and my inner OCD hates it.
  • Using units on line-height is generally discouraged, but provides immediate knowledge of what the computed value is. We'll probably try to steer away from this in the future.
  • In the future, we'll likely use ems for type sizing, perhaps rems even, but not for anything else. This is also debatable on font sizes for inputs and the like. It's just not how folks build pixel perfect sites.

That's a bit all over and hopefully coherent enough. I'll try to blog about these changes as they come up more, but I'm unsure how close 3.0 is and what that will all entail yet.

<3

mdo avatar Nov 20 '12 02:11 mdo