Page 1 of 1
CSS margin: 0 & margin: 0px ??
Posted: Sun Sep 28, 2003 1:32 am
by nigma
Hey, anyone know the diff between:
And:
Posted: Sun Sep 28, 2003 6:01 am
by jollyjumper
Hi Nigma,
There is no difference. There are a few different measurements in css, like px(pixels), pt(points), like there are in the real world(centimeter and inch for example), but 0 cm or 0 inch is still nothing.
So with 0 it isn't necesary to give a measurement.
Greetz Jolly.
Posted: Sun Sep 28, 2003 11:20 am
by nigma
Doesn't margin default to 0? Why would someone put margin: 0 when it is by default set to that?
Posted: Sun Sep 28, 2003 1:50 pm
by Cruzado_Mainfrm
i don't thing the margins are default set to 0px, for example in frames they are like 5px or something like that...
Posted: Sun Sep 28, 2003 3:14 pm
by evilMind
Cruzado_Mainfrm is correct. All browsers have different margins that they set by default for the html < body > < / body > tag.
Posted: Sun Sep 28, 2003 3:17 pm
by McGruff
Also they might be overiding something - for example by defining an inline style to overide a custom tag.
Posted: Sun Sep 28, 2003 3:57 pm
by nigma
Excellent guys, thanks a bunch!
Posted: Mon Sep 29, 2003 2:52 pm
by Unipus
Use 0px. If you try to validate your pages, they may not validate without a unit accompanying each measurement. It's just good practice to get into.
Posted: Mon Sep 29, 2003 2:57 pm
by microthick
I tend to base a lot of my CSS style off of examples from Jeffrey Zeldman's site. He uses 0 rather than 0px, so I use 0.
Posted: Mon Sep 29, 2003 3:07 pm
by Unipus
I'm surprised to hear that. Zeldman's usually got it all figured out. Maybe 0 is an exception to the rule, but if you try to validate any other measurement without a unit, it won't work.
Posted: Mon Sep 29, 2003 3:22 pm
by microthick
Yes, it seems to be the only case where he does it. But as jollyjumper said above, 0 cm is the same as 0 px, etc, so no unit is necessary I suppose.
Posted: Mon Sep 29, 2003 3:48 pm
by Unipus
Oh well. My point still stands: it's good practice to ALWAYS put a unit after your declarations.
Posted: Mon Sep 29, 2003 10:59 pm
by nigma
I actually just bought his book a few days ago.