Margins and the Margin Properties


One of the most common ways to specify spacing in your document is to adjust the margins. A margin is the space between the element's bounding box and the bounding box of any adjacent element. There are five margin properties; four let you set the margins for the left, right, top, and bottom margins individually or in any combination: margin-left, margin-right, margin-top, and margin-bottom.

The fifth one margin is a shortcut by which you can set all four margins in one step.

Name:

margin

Value:

[<length> | <percentage> | auto ] {1,4}

Initial:

0

Applies to:

all elements

Inherited:

no

Percentages:

refer to width of containing block


Name:

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

Value:

<length> | <percentage> | auto

Initial:

0

Applies to:

all elements

Inherited:

no

Percentages:

refer to width of containing block


margin can have between one and four values, the other four margins can have only a single value. The properties have three possible types of values. The default is 0, and negative values are acceptable:

  • Length Either an absolute or relative value.

  • Percentage A percentage of the width of the block-level element that contains this element, usually the parent element; for example, 10% means leave a space as large as 10% of the width of the parent element.

  • auto The auto value is discussed in detail in the section, "The whole story on width computation" later in this chapter.

These properties affect all content of an element (for example, all the lines of a paragraph). To set the margin for only the first line of a paragraph, see the section, "The text-indent property" in Chapter 7, "Space Inside Boxes."

Figure 8.3 shows example rules for using the margin-left, margin-right, margin-top, and margin-bottom properties.

Figure 8.3. (a) Initial situation, all margins zero. (b) Setting the left margin: margin-left: 3em. (c) Setting the right margin: margin-right: 25%. (d) Setting the top margin: margin-top: 5pt. (e) Setting top and bottom: margin-top: 1.2em; margin-bottom: 1.2em. (f) Setting left and right margins: margin-left: 5mm; margin-right: 5mm. (g) Negative margins: margin-left: 1cm; margin-right: -1cm.

[a] The artist is the creator of beautiful things. To reveal art and conceal the artist is art's aim. The critic is he who can translate into another manner or a new material his impression of beautiful things.

[b] The highest as the lowest form of criticism is a mode of autobiography. Those who find ugly meanings in beautiful things are corrupt without being charming. This is a fault.

[c] There is no such thing as a moral or an immoral book. Books are well written, or badly written. That is all.

[d] The nineteenth century dislike of realism is the rage of Caliban seeing his own face in a glass.

[e] The nineteenth century dislike of romanticism is the rage of Caliban not seeing his own face in a glass. The moral life of man forms part of the subject-matter of the artist, but the morality of art consists in the perfect use of an imperfect medium.

[f] No artist desires to prove anything. Even things that are true can be proved. No artist has ethical sympathies. An ethical sympathy in an artist is an unpardonable mannerism of style. No artist is ever morbid. The artist can express everything.

[g] Thought and language are to the artist instruments of an art. Vice and virtue are to the artist materials for an art. From the point of view of form, the type of all the arts is the art of the musician. From the point of view of feeling, the actor's craft is the type. All art is at once surface and symbol. Those who go beneath the surface do so at their peril.

OSCAR WILDE




Cascading Style Sheets(c) Designing for the Web
Cascading Style Sheets: Designing for the Web (3rd Edition)
ISBN: 0321193121
EAN: 2147483647
Year: 2003
Pages: 215

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net