Over the years, I have wasted a lot of time on "guessing" what would work and what would not work. Anyone just starting with CSS or looking to modify someone else's CSS will hopefully find these tips helpful and time saving.
Padding or Margin? These two attributes are often used, and more often confused. The margin attribute defines the space around an HTML element's border. The padding attribute refers to the space within the border.
Example:
p.marginex { margin:20px; border:1px solid #ccc; }
p.paddingex { padding:20px; border:1px solid #ccc; }
This illustrates using margins.
This illustrates using padding.
Class(.) selector or ID(#)? selector I explained the usage of classes v. IDs in an earlier post but this is something that still confuses people. Classes are used over IDs when you have something that might repeat on a page. IDs are used for unique items like header, navbar, container, footer. My rule of thumb: if there is a possibility for something to appear multiple times on the same page, use a class, if not, use an ID.
How do I deal with line breaks without tables? CSS is not for the light hearted, but using display: ... [more]