GeoffKnagge.com

Block Display Properties

All of the following are specific to visual media.

margin-top, margin-right, margin-left, margin-bottom

Valuelength | percentage | auto | inherit
Initial0
Used with all elements
Inherited no
Percentages relative to the width of the parent element
Example H1 { margin-top: 2em }

margin

Value [ [length | percentage | auto ]
[length | percentage | auto ]
[length | percentage | auto ]
[length | percentage | auto ]] | inherit
Used with all elements
Inherited no
Percentages relative to the width of the parent element
Example BODY { margin: 2em }
BODY { margin: 1em 2em }

This specifies the size of the top, right, bottom and left margins, in that order. If one value is given, it applies to all sides. If there are two or three, the values of the opposite sides are used for the missing ones.

padding-top, padding-right, padding-bottom, padding-left

Valuelength | percentage | inherit
Initial0
Used with all elements
Inherited no
Percentages relative to the width of the parent element
Examples P { padding-top: 0.3em }
P { padding-right: 10px }
P { padding-left: 20% }

padding

Value [ [length | percentage ] [length | percentage ]
[length | percentage ] [length | percentage ]] | inherit
Used with all elements
Inherited no
Percentages relative to the width of the parent element

Specifies the size of the top, right, bottom and left paddings, in that order. If one value is given, it applies to all sides. If there are two or three values, the values of the opposite sides are used for the missing ones.

border-top-width, border-right-width, border-bottom-width, border-left-width

Valuethin | medium | thick | length | inherit
Initialmedium
Used with all elements
Inherited no
This property sets the width of an element's border.

border-width

Value [thin | medium | thick | length] [thin | medium | thick | length] [thin | medium | thick | length] [thin | medium | thick | length] | inherit
Used with all elements
Inheritedno
If one value is given, it applies to all borders. For two values, the first is applied to the top and bottom, the second to the sides. If three values are specified, they apply to the top, sides, bottom respectively. If four values are given, they are assigned to the top, right, bottom and left respectively.

border-color

Valuecolor, color, color, color | inherit
Initial the element's color
Used with all elements
Inheritedno

The 'border-color' property sets the color of the four borders. The number of values specified produces the same results as for border-width.

border-top-style, border-right-style, border-bottom-style, border-left-style

| inherit
Valuenone | dotted | dashed | solid | double | groove | ridge | inset | outset
Initial none
Used with all elements
Inheritedno

The values for this element are specified, as for border-width. Some values which may not be self-explanatory include solid (solid line), double(double line) and groove, ridge, inset and outset, which produce 3D effects

border-style

Value [up to 4 border style types] | inherit
Initial none
Used with all elements
Inheritedno

The values for this element are specified, as for border-width. Some values which may not be self-explanatory include solid (solid line), double(double line) and groove, ridge, inset and outset, which produce 3D effects

border-top, border-left, border-bottom, border-right

Valueborder-xxx-width || border-style || color
Used with all elements
Inheritedno

Sets the appearance of the border for the given side.

border

Valueborder-width || border-style || color
Used with all elements
Inheritedno

The 'border' property is a shorthand method for setting the same width, color and style on all four borders of an element.

width

Valuelength | percentage | auto | inherit
Initialauto
Used with block-level and replaced elements
Inherited no
Percentage values relative to width of parent element

Sets the width of an element, scaling it if necessary.

min-width

Valuelength | percentage | inherit
Used with non-table elements
Inherited no
Percentage values relative to width of parent element

Sets the minimum allowed width of an element.

max-width

Valuelength | percentage | none | inherit
Initialnone
Used with non-table elements
Inherited no
Percentage values relative to width of parent element

Sets the maximum allowed width of an element.

height

Valuelength | auto | inherit
Initialauto
Used with block-level and replaced elements
Inherited no

Sets the height of an element.

min-height

Valuelength | inherit
Initial0
Used with non-table elements
Inherited no
Percentage values relative to height of parent element

Sets the minimum allowed height of an element.

max-height

Valuelength | percentage | none | inherit
Initialnone
Used with non-table elements
Inherited no
Percentage values relative to height of parent element

Sets the maximum allowed height of an element.

float

Valuenone | left | right | inherit
Initial none
Used withall elements
Inheritedno
ExampleIMG { float: left;}

Moves the element towards one side, wrapping text around it.

clear

Valuenone | left | right | both | inherit
Initial none
Used withall elements
Inheritedno
This property lists the sides where floating elements are not accepted.

position

Valuestatic | relative | absolute | fixed | inherit
Initialstatic
Used withall normal elements
Inheritedno
The values of are one of :
  • static : This is the normal value. left and top are ignored.
  • relative : The object is moved from where its normal position would be, and other objects are displayed as if it hadn't been moved.
  • absolute :The position and size of the object is determined by the left, right, top, and bottom properties, which are specified relative to the object in which the element is contained.
  • fixed : Same are absolute, but the element is fixed with respect to a reference. For normal screen type display, the element doesn't move when scrolled. With paged media, it is fixed with respect to the page

top, left, bottom, right

Valuelength | percentage | auto | inherit
Initialauto
Used withall non-static elements
Inheritedno

z-index

Valueinteger | auto | inherit
Initialauto
Used withall non-static elements
Inheritedno
CSS2 supports layering of elements, and this property allows you to specify how high the element is when it is amongst a pile of other elements.

The integer is the level within the current stacking context, unless is is zero in which case it sets up a local context. Higher numbers are further towards the top. If auto is used, the level is the same as the element in which it is contained.

All elements are transparent unless a background is specified.

direction

Valueltr | rtl | inherit
Initialltr
Used withall elements
Inheritedyes
This allows you to set the direction in which text is displayed : left-to-right, or right-to-left. It also affects the direction in which table columns are displayed.

To change the text in inline-level elements, the unicode-bidi property's value must be embed or override.

unicode-bidi

Valuenormal | embed | bidi-override | inherit
Initialnormal
Used withall elements
Inheritedno
  • embed : For inline elemments, this allows the direction of text to be given by the 'direction' property.
  • bidi-override :For inline of block elements, this causes an override, with the direction of display set by the direction property.

line-height

Valuenormal | number | length | percentage | inherit
Initialnormal
Percentagesrelative to the font size for the element
Used withall elements
Inheritedyes

vertical-align

Valuebaseline | sub | super | top | text-top | middle | botom | text-bottom | length | percentage | inherit
Initialbaseline
Percentagesrelative to the line-height for the element
Used withinline and table cell elements
Inheritedno
Some of the special values include :
  • baseline : Align the baseline of the element with that of its parent.
  • sub, super :effectively creates subscripts and superscripts
  • text-top, text-bottom :Align the top/bottom of the element with that of its parent.
  • percentage, length : Positive values raise the element by the given distance.

overflow

Valuevisible | hidden | scroll | auto | inherit
Initialvisible
Used withblock elements
Inheritedno
Occasionally, the content given to an element is too wide for the space allocated to it. This property is used to indicate what should be done in such circumstances : make it visible outside the allocated space, make the parts which extend beyond the allocated boundaries hidden, make it visible by use of scrollbars, or let the viewing program automatically decide (usually causes scrollbars).

clip

Valueshape | auto | inherit
Initialauto
Used withblock elements
Inheritedno
This property specifies what part of the element is visible if it is too big for the entire object to fit into the allocated space. It is used than overflow is anything other than visible.

CSS2 only allows one value for shape :
  • rect (top right bottom left). Each dimension is either auto or a length, and specifies the offset from each side of the box.

visibility

Valuevisible | hidden | collapse | inherit
Initialinherit
Used withall elements
Inheritedno

This property defines if an element is actually displayed, even though space is left for it. collapse should only be used on table rows and columns, otherwise it is the same as 'hidden'.
(C)opyright, Geoff Knagge.
Continued use of this site indicates your agreement to the Conditions of use and Privacy Policy.