/    Sign up×
Community /Pin to ProfileBookmark

EM’s VS %

What is best practice to use when styling up your markup % or em’s?

or a combination of the 2?

I i have always used em’s for fonts/expanding layouts but %’s for wrappers/containers in fluid layouts.

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@bathurst_guyJul 08.2007 — I would probably go with percent rather than em as I wouldn't want the page layout to change if the end user modifies their text size. It depends on what though, I might prefer to use em for a navigation menu.
Copy linkTweet thisAlerts:
@knowjauthorJul 08.2007 — I was just thinking about the problem with text expanding outside the containers with held with in which is a common problem i come across when testing a site for accessibility.

It's mainly to get some personal opinions as with the web there is rarely a fixed method/standard with these types of things. with pros and cons to all methods.

I'm starting to think its all based on the site design which you choose.
Copy linkTweet thisAlerts:
@____MaNiC_MoE____Jul 08.2007 — It depends on how you're gonna use it. I usually use the [B]Percentage (%)[/B] and [B]Pixels (px)[/B].

It's better to use the percentage, if you wanna do comparisons or like say, this element is gonna be smaller than this by 30% etc.

The following are some examples :

[code=html]
<style type="text/css">

/* Horizontal Bars */
hr.quarter {width:25%}
hr.half {width:50%}
hr.three-quarters {width:75%}
hr.full {width:100%}

</style>
[/code]


In the above case, using the [B]percentage[/B] is better than the [B]em[/B].



[code=html]
<style type="text/css">
h1 {letter-spacing:2em}
h2 {letter-spacing:4em}
</style>
[/code]


There, it's easier to use the [B]em[/B], if you use the percentage, you're gonna have to write values that are too small...

thx, hope this helped ?

correct me, if I'm wrong..
×

Success!

Help @knowj spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...