When should I use margin-left:auto; margin-right:auto to center and when should I use margin-left:50%; margin-right:50%?
Maybe “auto” when I am centering something contained in another element & 50% when I am centering on the page?
Or I am I just hopelessly confused?
Maybe 🙂
margin-left: 50%; margin-right: 50%is not generally useful: http://jsfiddle.net/VcDYr/margin-left: 50%is if you’re centering like this: http://jsfiddle.net/VcDYr/1/margin-left: auto; margin-right: auto. A shorter way to write this ismargin: 0 auto: http://jsfiddle.net/VcDYr/2/Consider that
divis a block-level element.See: http://www.w3.org/TR/CSS21/box.html#margin-properties
Which leads to: http://www.w3.org/TR/CSS21/visudet.html#Computing_widths_and_margins