22.12.2013 Views

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The background style of the various areas of a box are determined as follows:<br />

Content area: The ’background’ property of the generating element.<br />

Padding area: The ’background’ property of the generating element.<br />

Border area: The border properties [p. 88] of the generating element.<br />

Margin area: Margins are always transparent.<br />

8.2 Example of margins, padding, and borders<br />

This example illustrates how margins, padding, and borders interact. The<br />

example HTML document:<br />

<br />

<br />

<br />

Examples of margins, padding, and borders<br />

<br />

UL {<br />

background: green;<br />

margin: 12px 12px 12px 12px;<br />

padding: 3px 3px 3px 3px;<br />

/* No borders set */<br />

}<br />

LI {<br />

color: black; /* text color is black */<br />

background: gray; /* Content, padding will be gray */<br />

margin: 12px 12px 12px 12px;<br />

padding: 12px 0px 12px 12px; /* Note 0px padding right */<br />

list-style: none /* no glyphs before a list item */<br />

/* No borders set */<br />

}<br />

LI.withborder {<br />

border-style: dashed;<br />

border-width: medium; /* sets border width on all sides */<br />

border-color: black;<br />

}<br />

<br />

<br />

<br />

<br />

First element of list<br />

Second element of list is longer<br />

to illustrate wrapping.<br />

<br />

<br />

<br />

results in a document tree [p. 30] with (among other relationships) a UL<br />

element that has two LI children.<br />

The first of the following diagrams illustrates what this example would produce.<br />

The second illustrates the relationship between the margins, padding, and<br />

borders of the UL elements and those of its children LI elements.<br />

83

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!