One oddity with the
margin
property is that vertical margins, top
and bottom
, are not accepted by inline-level elements. These vertical margins are, however, accepted by block-level and inline-block elements.Padding
The
padding
property is very similar to the margin
property; however, it falls inside of an element’s border, should an element have a border. The padding
property is used to provide spacing directly within an element. Here’s the code:
The
padding
property, unlike the margin
property, works vertically on inline-level elements. This vertical padding
may blend into the line above or below the given element, but it will be displayed.Margin & Padding on Inline-Level Elements
Inline-level elements are affected a bit differently than block and inline-block elements when it comes to margins and padding. Margins only work horizontally—
left
and right
—on inline-level elements. Padding works on all four sides of inline-level elements; however, the vertical padding
—the top
and bottom
—may bleed into the lines above and below an element.
Margins and padding work like normal for block and inline-block elements.
No comments:
Post a Comment