2 replies [Last post]
gautamz07
gautamz07's picture
Offline
Enthusiast
Last seen: 6 years 10 weeks ago
Timezone: GMT+5.5
Joined: 2014-04-24
Posts: 265
Points: 403

I often see em's used in place where really it should have been pixels ex.

@media only screen and (min-width: 35em) {
    /* Style adjustments for viewports that meet the condition */
}

now why would somebody use em's like that ?? how does the author know how much is 35em's really going to be ? i guess when your setting a media query you need to know mentally what screen size that media query is going to be activated at , now if you say 35em , what screen size would that mean ..... ??? i just don't get it , why do people use em's in media queries ?

P.S. :: I know the web would is moving away from pixels to em's and rems Wink

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 1 year 38 weeks ago
Dallas
Timezone: GMT-6
Joined: 2004-06-25
Posts: 9776
Points: 3858

Proportionality

Using 'em' makes dimensions proportional to the user's preferred font size. It has its rationale, but I probably agree with you that media queries are better served by pixel bounds; the viewport doesn't care what the font size is.

That said, I haven't really worked through the em based queries enough to talk intelligently about them. Generally, I prefer to set wrapper, column widths, &c. by percentage and break-points by px. {shrug}

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

gautamz07
gautamz07's picture
Offline
Enthusiast
Last seen: 6 years 10 weeks ago
Timezone: GMT+5.5
Joined: 2014-04-24
Posts: 265
Points: 403

Thanks for your views gary

Ok. thanks for your view gary, anyways , the world seems to be obsessed with em's and so pretty soon i guess even for media-queries i will migrate to em's.