Code Editor
Web Browser

Margin IV

If you want to be even more specific about the amount of margin on each side of a box, you can use the following properties:

  1. margin-top
  2. margin-right
  3. margin-bottom
  4. margin-left

Each property affects the margin on only one side of the box, giving you more flexibility in customization.

p { border: 3px solid #2D3FA3; margin-right: 15px; }

In the example above, only the right side of the paragraph's box will have a margin of 15 pixels.

Because the margin property directly modifies the space outside of a box, it's very common to see margin values used for only specific sides of boxes. As you learn more about web development, you'll likely come across many different ways of positioning elements with the margin property.

Report a Bug
If you see a bug or any other issue with this page, please report it here.