Prev | Current Page 119 | Next

Charles Wyke-Smith

"Stylin' with CSS: A Designer's Guide 2nd Edition"


If space is tight and you don??™t want spaces between paragraphs, you
can set the margin top and margin bottom values of the paragraphs
to 0 and use indents or negative indents instead of vertical space to
provide a clear indication of where each paragraph starts.
STYLIN??™ WITH CSS - CHAPTER 3 88
Inherited Values are Computed Values
One more important note here: text-indent is inherited by child elements.
For example, if you set a text-indent on a
div, all the paragraphs inside the div will have that text-indent value.
However, as with all inherited CSS values, it??™s not
the de?¬? ned value that??™s passed down but the computed value. Here??™s an example
that explains the implications of this fact.
Let??™s say you have a div containing text that??™s 400 pixels wide with a 5
percent text indent. If this is the case, the indent for that text is 20 pixels
(5 percent of 400). Within the div is a paragraph that??™s 200 pixels wide.
As a child element, the paragraph inherits any text-indent value, so it is
indented too, but the value it inherits is the result of the calculation made on
the parent, that is, 20 pixels, not the de?¬? ned 5 percent. As a result, it too has
a 20 pixel indent even though it??™s half the width of the parent element. This
ensures that all the paragraphs have nice matching indents, regardless of
their widths.


Pages:
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131