HTML and CSS Reference
In-Depth Information
Margins go outside an element's border, but adjacent vertical margins overlap and collapse to the size of the
largest margin. The background of the parent element shows through margins. Horizontal and vertical space
around an element can be controlled independently on each side by using specific properties, such as
padding-top
and
margin-left
, or by using the
padding
and
margin
shorthand properties. As long as an element
has a declared width, you can center it by setting its left and right margins to
auto
.
In addition to setting the
width
and
height
properties, you can limit the dimensions of an element within
a range by using
min-width
,
max-width
,
min-height
, and
max-height
, which are supported by all browsers
except IE 6.
Browsers treat most elements as block-level or inline boxes, but the
display
property allows you to change
the default box type. Setting
display
to
none
hides an element and all its children by removing it completely from
the document flow. Setting
visibility
to
hidden
also hides an element, but it leaves a space where the element
would normally be. The overflow properties control what happens when an element's content is too big.
There's a lot of information to absorb in this chapter. Take your time to make sure it sinks in. In the next
chapter, you'll learn about another fundamental aspect of current page layout—using the
float
property to ow
text around images and position block-level elements alongside each other.