CSS Margins

These are some of the commonly used CSS properties related to margins:

margin-top, margin-right, margin-bottom, and margin-left: these properties allow you to set the individual margins of each side of an element. For example, "margin-left: 10px;" will create a margin of 10 pixels on the left side of an element.

margin: this property allows you to set all four margins at once, in the order of top, right, bottom, and left. For example, "margin: 10px 20px 10px 20px;" will create a margin of 10 pixels on the top and bottom, and 20 pixels on the right and left.

margin:auto: this property allows you to center an element horizontally within its container. For example, "margin: 0 auto;" will center the element horizontally.

margin-collapse: this property is used when two or more elements have adjacent margins. It specifies how the margins should collapse into a single margin. The possible values are "collapse", "separate", and "inherit".

padding: this property sets the amount of space between the element's content and its border. For example, "padding: 10px;" will create a padding of 10 pixels around the element's content.

Last updated