1

I've recently started learning HTML and CSS.

In regards to the 'margin' property: Is the main purpose of this property to center elements horizontally on the web page?

I created a navigation for a site, but I don't see any reason to use the margin property. Why would someone use the margin property for a site's navigation?

Edson
  • 245
  • 1
  • 3
  • 14
  • 1
    possible duplicate of [When to use margin vs padding in CSS](http://stackoverflow.com/questions/2189452/when-to-use-margin-vs-padding-in-css) – showdev Feb 02 '15 at 19:36
  • 2
    No. it's not just for centering. You should learn about the CSS [box model](https://developer.mozilla.org/en-US/docs/Web/CSS/box_model) – Marc B Feb 02 '15 at 19:38
  • Thanks for the link. I also was able to get my hands on a HTML & CSS book that said what Michael Wagner said below. – Edson Feb 02 '15 at 23:34

1 Answers1

0

Margin is the outer distance of one element to other ones. Centering is just one usage of this (the left and right value are set to the same). You should take a look at the link in Marc B's comment.

Michael Wagner
  • 998
  • 7
  • 20