As I am trying to learn CSS, I am looking at lots of peoples code, and see both px and % used for margins. When I experiment with CSS myself, I sometimes end up using both px and % for my margins as well....
Is this bad form to have them both mixed in your CSS?
Is there a general rule or preferance on using px or % when defining margins?
px are fixed width. Meaning if you give your body a margin left and rigth of 20 px, you get just that. % in margins give you screen proportion. Meaning if you give your body a margin left and right of 20% percent, the browser will compensate for whatever resolution you are on. From what I know, it doesn't matter if you intermix them. You could give your body left and right of % and a paragraph later down the road a margin left of a specified amount in pixels.
It doesn't matter if you mix and match, although you might get odd results at very large or very small resolutions. It's better to be consistent, though, so choose what works best for you and stick to it.