Collected by
Elizabeth Janson

Home Page

Container Box Shorthand

 

Block elements you can define are:
  BLOCKQUOTE 
  TABLE
  FORM
  FIELDSET
  ADDRESS
  NOSCRIPT 
  PRE
  DIV
  P
  UL 
  OL
  DL
  H1 
  H2
  H3
  H4
  H5
  H6
  HR

Each block-level element, and some in-line elements, are container boxes, with each side having a margin, padding, border-width, border-color, and border-style, all summarised as border.

Some properties are shorthand properties, meaning they allow authors to specify the values of several properties with a single property. An example is the 'font' property described on another page. When values are omitted from a shorthand form, each "missing" property is assigned its initial value, or it's previously used value cascades to this element.
For this reason, no BORDER is visible unless it has 'border-style' set, since the initial value of the border-style is 'none'.

The 'padding' property

Unlike margin properties, values for padding values cannot be negative. Like margin properties, percentage values for padding properties refer to the width of the generated box's containing block.

The 'padding' property is a shorthand property for setting 'padding-top', 'padding-right', 'padding-bottom', and 'padding-left' at the same place in the style sheet.

The surface colour or image of the padding area is specified via the 'background-color' property:

Example(s):

My Padding

H1 { 
  background-color: green; 
  padding: 1em 3em;
  color: gold;
} 

The green example above specifies a '1em' vertical padding ('padding-top' and 'padding-bottom') and a '3em' horizontal padding ('padding-right' and 'padding-left'). The 'em' unit is relative to the element's font size: '1em' is equal to the size of the font in use.

The 'border' property

The border-width properties are thin, medium or thick and are a shorthand property for setting 'border-top-width', 'border-right-width', 'border-bottom-width', and 'border-left-width' at the same place in the style sheet.

The 'border-color' property sets the colour of the four borders. Values are a colour name, HEX value to stay W3C compliant, or transparent. The 'border-color' property can have from one to four values, and the values are set on the different sides, in clockwise order, as for 'border-width'.

The border-style values are none, hidden, 'dotted', 'dashed', 'double', 'groove', 'ridge', 'inset', and 'outset', 'solid'.
Remember, the initial value of the border styles is 'none', so no borders will be visible unless the border style is set.

'border-top', 'border-bottom', 'border-right', 'border-left', and 'border' can be set with width, style and color.

Example:

H1 { border-bottom: thick solid red }

Fancy heading

WHOPS, will SPAN shorten the line? No. Put it in a table? YES! but STYLE is supposed to be removing the need to use tables for control like that!

Fancy heading

The above rule set the width, style, and color of the border below the H1 element (and the whole line, as that is how H1 is designed).

Border shorthand properties

The 'border' property is a shorthand property for setting the same width, color, and style for all four borders of a box. Unlike the shorthand 'margin' and 'padding' properties, the 'border' property cannot set different values on the four borders. To do so, one or more of the other border properties must be used.

Email
CSS begins here
Back to margins, or on to Cascading order.

This page is part of Elizabeth Janson's web site

http://www.oocities.org/elizatk/index.html

My other sites are the Anglican Parish of Northern Mallee,
Tetbury residents in the Eighteenth Century
my Australian Family History and Barrie, our Family Poet.