twbs / bootstrap

The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.
https://getbootstrap.com
MIT License
170.82k stars 78.86k forks source link

Pixels vs EM & Vertical Rhythm #1943

Closed ifesdjeen closed 12 years ago

ifesdjeen commented 12 years ago

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).

mdo commented 12 years ago

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.

ifesdjeen commented 12 years ago

@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.

chrisnicola commented 12 years ago

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.

davideicardi commented 12 years ago

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

DrummerHead commented 12 years ago

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

opensource21 commented 12 years ago

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

Undistraction commented 12 years ago

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

martent commented 12 years ago

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.

RonaldV commented 12 years ago

+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.

Charuru commented 12 years ago

If anything em removes complexity.

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

martent commented 12 years ago

@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.

luishdez commented 12 years ago

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.

Undistraction commented 12 years ago

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

alex-ross commented 12 years ago

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.

livingincircuits commented 12 years ago

+1 for more information regarding this.

ghost commented 11 years ago

+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?

austinbirch commented 11 years ago

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.

danielmahon commented 11 years ago

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

Charuru commented 11 years ago

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.

mdo commented 11 years ago

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

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

gavrochelegnou commented 11 years ago

I think this was not raised here, but using em instead of pixels is also important for web accessibility. Using "px" results in a failure of test C14 from the W3C/WCAG http://www.w3.org/TR/WCAG-TECHS/C14.html

Quite a shame for all website under section 508 (and other accessibility laws around the world)

luishdez commented 11 years ago

@gavrochelegnou :+1:

rossedman commented 11 years ago

I actually had a discussion about this today with some other developers and behold this conversation is happening. I have read the reasons why ems are not being used in bootstrap. However as someone who was a designer first and a developer second I can tell you I don't think in pixels and it's kind of belittling to here that designers still think in pixels. I know many designers who think much more deeply about their designs. I think of mine in ratios and in vertical rhythm more than pixels.

I hope you guys will reconsider but I have already cut this out of production based on this reason alone. Everything else is great about this framework.

mdo commented 11 years ago

It's kind of belittling to here that designers still think in pixels.

I know many designers who think much more deeply about their designs.

I'm just going to call these two statements out and call it a day. There are no ill intentions in the statements I made and if you reread what I wrote, you'll see I'm explaining the thinking to date and not any decision that's been made for 3.0. We'll do whatever makes the most sense for the constraints that we can define and take it from there.

kogcyc commented 11 years ago

+1 for making em an option

rossedman commented 11 years ago

Hey I wasn't trying to start anything. There was no malice in this. I was just responding to your statement. Sorry for any problems you had with this. You don't owe me a reason for you thinking. It is your development. I thought this was a conversation and it seems many other people would like to hear you reconsider. I honestly don't care either way. I will continue to use what works for me and am thankful that someone even wanted to develop something like this.

simonwiles commented 11 years ago

wow - this is a surprising discussion. hoping you'll consider em-based units for v3!

stationkeeping commented 11 years ago

For anyone looking for em-based, truly responsive layouts, we switched to Suzy a while ago and haven't looked back. It makes it easy to visualize in pixels, but execute in ems. Also Thoughtbot have been busy on Bourbon which has a Layout library and a new UI library. It's still early days, but is looking great. If you know Thoughtbot, you'll know this is worth keeping an eye on.

gavrochelegnou commented 11 years ago

To comply with accessibility standards we switched to Yaml

aleemb commented 11 years ago

Have you considered reevaluating this issue for the next major release?

Some pretty good arguments for it are made here: http://trentwalton.com/2013/01/07/flexible-foundations/

The compounding problem is trivially remedied (1em or 100% sizing for base elements).

timmarinin commented 11 years ago

+1 for em support, 'cause px is not responsive. I truly hope for ems in v3.

Undistraction commented 11 years ago

So there are no plans to support ems in V3?

ConlinJoe commented 11 years ago

The reasoning as I see it is quite simple..EM based layouts are much more complicated for not just the framework dev team but also for developers who are contemplating adoption. I have tried more of the frameworks than I care to admit and ended up on Foundation for a while until I moved to Bootstrap. The reason i switched over to Bootstrap in the first place was that i liked the thought of a framework with amazing talent behind it as well an an exploding community. Having been using it for the past 6 months I have to say that I am now at a point to either port the framework over to an EM/REM based framework, switch back to Foundation (except I love the simplicity of LESS) or finish a framework that I was building myself.

Someone above stated that a fixed pixel based layout is not truly responsive and this is absolutely correct. The thought of using media queries to change PX sizes does nothing but bloat the code and really detract from the true nature of fluid measurements that adapt to screen size. Not that that you still don't use media queries, just not to micro manage fixed pixel sized elements. Furthermore, we only have a few break points to deal with right now but at the pace that tablets and non-desktop devices are gaining traction, it won't long before this won't be the case, at which point it will no longer be truly adaptive to ALL screen sizes.

In the end, I think that the Boostrap devs decision for a PX based layout was smart because many more entry to mid level developers could start using it easily and gaining experience with responsive layouts. For the rest of us, who care about things like accessibility, true vertical rythm and have no need for everything to be SO canned, the reality is that it is more effort to use than not. Trust me, I wish this wasn't true as I have just spent 6 month getting intricately familiar with a framework only to bail it, but that's how it goes in this biz...won't be the first time and surely won't be the last.

I would love to know if there is a REAL desire out there for an EM port of bootstrap...I would do it if I knew there was a decent interest.

newtriks commented 11 years ago

+1 for em support

jfroom commented 11 years ago

+1 for em support

jfroom commented 11 years ago

This issue has rattled me a bit as well - which is a bummer because I heart bootstrap's intent. Came across another write up about benefits of EMs: http://blog.cloudfour.com/the-ems-have-it-proportional-media-queries-ftw/

binarylogic commented 11 years ago

Couldn't agree me. Foundation uses a emCalc function to make it easy. Even line heights are px based, wtf...

jfroom commented 11 years ago

Found the Bootstrap 3 road map here: https://github.com/twitter/bootstrap/pull/6342

In the Type section is this comment: Explore use of rem instead of px as typographic unit... So that is a good sign. (I only recently discovered the utility of rem over an em - it does sound preferable in most cases.)

Foundation4 http://foundation.zurb.com/ is mostly em based (from what I've seen so far), has super organized sass libraries, and is mobile first. Looking forward to Bootstrap 3 because the community is so much larger - but until that stabilizes, I switched over to Susy and then to Foundation few days ago for my current project du jour.

nathanpitman commented 11 years ago

+1 for ems in place of pixels. It might be a lot of work to make it happen but I think the long term benefits are far greater. :)

cdeutsch commented 11 years ago

+1 for ems. It's about the only thing on my wish list for Bootstrap. Love it otherwise.

lenkite commented 11 years ago

+1 for root ems

evgenyneu commented 11 years ago

+1 for EMs

jahvi commented 11 years ago

+1 for rems/ems, at least for type and line height that'd be a great starting point

luis-ca commented 11 years ago

+1 for EMs

jahvi commented 11 years ago

Sounds like it's not happening for 3.0 :cry:

We explored the use of rem units over pixels, but found little benefit to offset the implications of their use. IE8 would still need a pixel fallback, and that's a lot of duplicate lines of code. Moreover, using rems everywhere instead of pixels would exacerbate that problem. Mixing rems and pixels doesn't seem to make sense either right now. However, we can and will continue to evaluate this in future releases.

ConlinJoe commented 11 years ago

Due to the lack of support in older versions of IE, I only use rem units only in defining my initial typography styles from my base settings. From there I use regular em units which offer relative sizing to the parents of a selector. I find that this cuts down on the code needed in media queries as an adjustment to the parent relationally adjusts its siblings.

When I do use rem units, I simply add the pixel sizing preceding it to ensure proper fallback support. The additional code is very minimal to ensure this support. For example:

h1 {font-size: 30px; font: 2rem/1.2 sans-serif;}

While you could argue this is a bit redundant and not needed (you could just use pixel sizing), I do it because to me it is best practice with added fallback support, which will be dropped when the time comes.

In regards to an em port, I have been working on it but am only going to release it for v3 as the many of the changes are rather dramatic and for the most part, very positive (except for things such as changing the name to the .clearfix class that I haven't been able to figure out the reasoning for) so it doesn't make sense to maintain support for code soon to be deprecated.

Piedone commented 11 years ago

@vandigroup May I ask if the em port you mentioned is or will be public, and if yes, where?

ConlinJoe commented 11 years ago

I will create a repo for it here (on GH) soon and will be free for anyone to use. I will post a link here when it's up...

Piedone mailto:notifications@github.com May 10, 2013 12:14 PM

@vandigroup https://github.com/vandigroup May I ask if the em port you mentioned is or will be public, and if yes, where?

— Reply to this email directly or view it on GitHub https://github.com/twitter/bootstrap/issues/1943#issuecomment-17739054.

Joe Conlin [download vCard http://www.vandigroup.com/vCards/joeconlin.vcf]

Phone: (760) 705-4331 Email: joe@vandigroup.com Skype: joe.conlin Web: www.vandigroup.com http://www.vandigroup.com Connect: LinkedIn http://linkedin.com/joeconlin | Twitter http://twitter.com/joevandigroup | Google+ https://plus.google.com/u/0/100025626000241608217 | flikr http://www.flickr.com/x/t/0097002/photos/vandigroup/

"Vandigroup is a full-service, digital agency, specializing in technology and results driven solutions. Contact us today to see how we can help you."

Piedone commented 11 years ago

@vandigroup Great, thank you!

jahvi commented 11 years ago

Inuit.css uses a very nice mixin to handle type sizing in rems https://github.com/csswizardry/inuit.css/blob/master/generic/_mixins.scss#L13-L19

Fallback support could be suppressed fairly easy if needed later on.