Personal computing discussed

Moderators: renee, SecretSquirrel, just brew it!

 
flip-mode
Grand Admiral Gerbil
Topic Author
Posts: 10218
Joined: Thu May 08, 2003 12:42 pm

Sorry to ask but... HTML px or em

Tue Mar 30, 2010 1:00 pm

This is such a basic question :oops:

Is it OK to use px dimensions for all elements besides text - div, img, widths of block elements, etc?

I've used px to dimension all my block elements. How big a deal is that?
 
Nitrodist
Grand Gerbil Poohbah
Posts: 3281
Joined: Wed Jul 19, 2006 1:51 am
Location: Minnesota

Re: Sorry to ask but... HTML px or em

Tue Mar 30, 2010 1:08 pm

Image
 
flip-mode
Grand Admiral Gerbil
Topic Author
Posts: 10218
Joined: Thu May 08, 2003 12:42 pm

Re: Sorry to ask but... HTML px or em

Tue Mar 30, 2010 1:16 pm

Nitrodist wrote:

OK, not to be an ass, but just to clarify, that looks like it's basically saying that it is just fonts that should be sized with em, but other elements there is no reason not to use px??? :oops:
 
Nitrodist
Grand Gerbil Poohbah
Posts: 3281
Joined: Wed Jul 19, 2006 1:51 am
Location: Minnesota

Re: Sorry to ask but... HTML px or em

Tue Mar 30, 2010 1:28 pm

flip-mode wrote:
Nitrodist wrote:

OK, not to be an ass, but just to clarify, that looks like it's basically saying that it is just fonts that should be sized with em, but other elements there is no reason not to use px??? :oops:


I think what em units should be used for is for anything that has text in it (so basically anything).

This website I found gives some more insight to using em units for div tags and so forth. From skimming the article it was talking about how setting the size of the div box relative to the text inside of it is a better practice than setting a hard limit for pixels if you want the web site to scale from a small monitor to someone with a large monitor (I'm talking about monitor resolution, of course).

Quoting from the linked website:

DIV.menu { padding: 1.5em }

By specifying the padding width in ems, the width of the padding is relative to the font size of the div element. As a designer, you don't really care what the exact width of the padding is on the user's screen, what you care about is the proportions of the page you are composing. If the font size of an element increases, the padding around the element should also increase. This is shown in figure 2 where the font size of the menu has increased while the proportions remain constant. (You can learn more about padding in chapter 9 .)


I think that sufficiently explains how to use em's on a minimal scale. I am not experienced at all in designing websites, but for the websites that I have done it's evident that you can design very usable websites without the use of em units.
Image
 
flip-mode
Grand Admiral Gerbil
Topic Author
Posts: 10218
Joined: Thu May 08, 2003 12:42 pm

Re: Sorry to ask but... HTML px or em

Tue Mar 30, 2010 1:59 pm

Sweet Nitrodist, thanks for your patience.
 
titan
Grand Gerbil Poohbah
Posts: 3376
Joined: Mon Feb 18, 2002 7:00 pm
Location: Great Smoky Mountains
Contact:

Re: Sorry to ask but... HTML px or em

Tue Mar 30, 2010 5:24 pm

When I design a site I always use em. htmldog.com says that unless you have a need to specify px or pt, don't.

You have to bear in mind that what fits on your screen at 2560x1600 will not necessarily fit on a 1024x768. Or what appears large enough to your eyes may be too small for another.

I run into this problem quite often. I'll come upon a site that uses tiny font, but because nothing is relative, when I increase the font size, the layout is broken. And, when the layout is broken, the site in question tends to become illegible.

My eyes are fine, but I don't have an LCD monitor. So, there tends to be some blurriness with the text as it is. Determining the difference between an s and an e is not fun. It's rather infuriating, actually, when I'm reading command line options or code on a site.
The best things in life are free.
http://www.gentoo.org
Guy 1: Surely, you will fold with me.
Guy 2: Alright, but don't call me Shirley.

Who is online

Users browsing this forum: No registered users and 1 guest
GZIP: On