Is there any difference between
margin: 0;
and
margin: 0em;
I didn't notice anything, but my teacher keeps telling me that it's not the same.
Is there any difference between
margin: 0;
and
margin: 0em;
I didn't notice anything, but my teacher keeps telling me that it's not the same.
There's no difference when the value is 0. If it were 1 and 1em, yes, there's a difference, but 0 is 0, no matter the unit.
Google's own Chrome browser in the 'Computed' style includes units with zero values which aligns with my personal preference to just include it.
The file is bigger with 0em.
The way to prove to your professor that there is no difference is to set something to 0 and something else to 0em and inspect the DOM with Firebug or a similar tool. If I recall correctly, you'll see that both are now 0. So the only difference is in the source. (But it's been a while since I checked. I might be thinking of getting and setting styles from jQuery. So check it out before you take my word.)
I wonder if the teacher is trying to highlight, not so much that 0 and 0em are not the same value but perhaps, that the default unit in CSS may not be em (I believe the spec demands that non-zero values have units attached but often assume px).
On the specific example obviously they are equal.
It's like saying that 0 bananas is not the same as 0 apples. So in a way, he's correct, but zero is zero, so either way you'll end up hungry!
Your teacher, it appears, is an idiot.
But maybe appearances are deceptive: you should ask your teacher what they meant.
I have to ask, why didn't you ask your teacher what they meant when they first said it? Zero is zero, no matter what the units.