I can’t remember if I have to put an IMG into a separate DIV (or TABLE) to force two IMGs onto their own lines vertically (to stack, in other words). I’ve tried adding
to the second IMG but the two are still on the same line. Did I have to float this? What’s the simplest way to add a TOP MARGIN (not padding) to an IMG? Thanks guys!
A class implies properties that are selectively applied. Your question is a bit too vague to answer “globally”. Are you asking how to apply a margin-top to all tables, images, and divs? or are you asking for a class that can be selectively applied to any table, image and/or div?
You can’t really make blanket assumptions like that as margins collapse or will at least depend on the margin of the element above also.
If the element above has a greater margin that 35px then the gap will be greater than 35px or if the element above has a negative bottom margin the gap will be less.
If the elements are floated then the margins won’t collapse and you get double the margin you thought as margins on floats don’t collapse.
If the elements are nested then the margin will collapse onto the outer element if there is no content, borders or padding between them.
If you apply a 35px top margin to an element it will have no affect if the element above it is a float.
Vertical margins on inline elements are ignored.
So as you can see you can’t really have a one size fits all rule as it all depends on context. If you are just talking about static non floated, non positioned divs then just adding a margin-bottom is fine but at some point you will run into one or other of the scenarios mentioned above and have code more specifically to the task in hand.
It is unlikely that you would want all divs, images and tables to have the same margin. However you may want to set a default for elements like paragraphs and headings. (e.g. p{margin:0 0 1em})