Part 7. CSS issues and bugs

Trapping margins

This first example shows an h5 element with the margins poking out the top and bottom of its container.

Heading

The second example shows that the margins can be contained by using a small amount of padding on the container.

Heading

The third example shows that the margins can be contained by using a border on the container.

Heading

The fourth example shows that the problem can also be solved by applying padding, rather than margins to the heading element.

Heading