8000 csswg-drafts/css2/visudet.src at 396a3e911fac1d7220b743ac83e09f3b1ac783b6 · w3c/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
1411 lines (1104 loc) · 50.4 KB

File metadata and controls

1411 lines (1104 loc) · 50.4 KB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html lang="en">
<!-- $Id: visudet.src,v 1.26 1997-11-27 03:23:22 ian Exp $ -->
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<TITLE>Visual rendering model details</TITLE>
<LINK rel="next" href="page.html">
<LINK rel="previous" href="flowobj.html">
<LINK rel="STYLESHEET" href="style/default.css" type="text/css">
</HEAD>
<BODY>
<H1 align="center">Visual rendering model details</H1>
<H2>Box model properties</h2>
<H3><a name="margin-properties">Margin properties</a>:
<span class="propinst-margin-top">'margin-top'</span>,
<span class="propinst-margin-right">'margin-right'</span>,
<span class="propinst-margin-bottom">'margin-bottom'</span>,
<span class="propinst-margin-left">'margin-left'</span>, and
<span class="propinst-margin">'margin'</span></H3>
<P>Margin properties set the margin of an element. The
<span class="propinst-margin">'margin'</span> property sets the border
for all four sides while the other margin properties only set their
respective side.
<H4><a name="border-width-defs">Values for </a><span class="index-def"
title="&lt;margin-width&gt;, definition of"><a
name="value-def-margin-width">&lt;margin-width&gt;</a></span></H4>
<P>The properties defined in this section refer to the
<span class="value-inst-margin-width">&lt;margin-width&gt;</span>
value type, whose possible values may be:
<P><span class="value-inst-length">&lt;length&gt;</span> |
<span class="value-inst-percentage">&lt;percentage&gt;</span> |
auto</P>
<P>Negative values for margin properties are allowed, but there may be
implementation-specific limits.
<P>Percentage values for margin properties refer to the width of
the containing block.
<!-- #include src=properties/margin-top.srb -->
<P>This property sets the top margin of an element. It applies to
replaced and block-level elements.
<div class="example"><P>
<PRE>
H1 { margin-top: 2em }
</PRE>
</div>
<!-- #include src=properties/margin-right.srb -->
<P>This property sets the right margin of an element:
<div class="example"><p>
<PRE>
H1 { margin-right: 12.3% }
</PRE>
</div>
<!-- #include src=properties/margin-bottom.srb -->
<P> This property sets the bottom margin of an element. It applies to
replaced and block-level elements.
<div class="example"><P>
<PRE>
H1 { margin-bottom: 3px }
</PRE>
</div>
<!-- #include src=properties/margin-left.srb -->
<P> This property sets the left margin of an element:
<div class="example"><P>
<PRE>
H1 { margin-left: 2em }
</PRE>
</div>
<!-- #include src=properties/margin.srb -->
<P> The <span class="propinst-margin">'margin'</span> property is a shorthand
property for setting <span class="propinst-margin-top">'margin-top'</span>, <span
class="propinst-margin-right">'margin-right'</span> <span
class="propinst-margin-bottom">'margin-bottom'</span> and <span
class="propinst-margin-left">'margin-left'</span> at the same place in the style
sheet.
<P> If four length values are specified they apply to top, right,
bottom and left respectively. If there is only one value, it applies
to all sides, if there are two or three, the missing values are taken
from the opposite side.
<div class="example"><P>
<PRE>
BODY { margin: 2em } /* all margins set to 2em */
BODY { margin: 1em 2em } /* top &amp; bottom = 1em, right &amp; left = 2em */
BODY { margin: 1em 2em 3em } /* top=1em, right=2em, bottom=3em, left=2em */
</PRE>
<P> The last rule of the example above is equivalent to the example
below:
<PRE>
BODY {
margin-top: 1em;
margin-right: 2em;
margin-bottom: 3em;
margin-left: 2em; /* copied from opposite side (right) */
}
</PRE>
</div>
<H3><a name="padding-properties">Padding properties</a>:
<span class="propinst-padding-top">'padding-top'</span>,
<span class="propinst-padding-right">'padding-right'</span>,
<span class="propinst-padding-bottom">'padding-bottom'</span>,
<span class="propinst-padding-left">'padding-left'</span>, and
<span class="propinst-padding">'padding'</span>
</H3>
<P> The
padding properties describe how much space to insert between the
border and the content (e.g., text or image). The <span
class="propinst-padding">'padding'</span> property sets the padding
for all four sides while the other padding properties only set their
respective side.
<H4><a name="padding-width-defs">Values for </a><span class="index-def"
title="&lt;padding-width&gt;, definition of"><a
name="value-def-padding-width">&lt;padding-width&gt;</a></span></H4>
<P>The properties defined in this section refer to the
<span class="value-inst-padding-width">&lt;padding-width&gt;</span>
value type, whose possible values may be:
<P><span class="value-inst-length">&lt;length&gt;</span> |
<span class="value-inst-percentage">&lt;percentage&gt;</span></P>
<P>Unlike margin properties, values for padding values cannot be
negative.
<P>Like margin properties, percentage values for padding properties
refer to the width of the containing block.
<!-- #include src=properties/padding-top.srb -->
<P> This property sets the top padding of an element.
<div class="example"><P>
<PRE>
BLOCKQUOTE { padding-top: 0.3em }
</PRE>
</div>
<!-- #include src=properties/padding-right.srb -->
<P> This property sets the right padding of an element.
<div class="example"><P>
<PRE>
BLOCKQUOTE { padding-right: 10px }
</PRE>
</div>
<!-- #include src=properties/padding-bottom.srb -->
<P> This property sets the bottom padding of an element.
<div class="example"><P>
<PRE>
BLOCKQUOTE { padding-bottom: 2em }
</PRE>
</div>
<!-- #include src=properties/padding-left.srb -->
<P> This property sets the left padding of an element.
<div class="example"><P>
<PRE>
BLOCKQUOTE { padding-left: 20% }
</PRE>
</div>
<!-- #include src=properties/padding.srb -->
<P> The <span class="propinst-padding">'padding'</span> property is a
shorthand property for setting <span
class="propinst-padding-top">'padding-top'</span>, <span
class="propinst-padding-right">'padding-right'</span>, <span
class="propinst-padding-bottom">'padding-bottom'</span>, and <span
class="propinst-padding-left">'padding-left'</span> at the same place in the style
sheet.
<P> If four values are specified they apply to top, right, bottom and
left respectively. If there is only one value, it applies to all
sides, if there are two or three, the missing values are taken from
the opposite side.
<P> The surface of the padding area is set with the <span
class="propinst-background">'background'</span> property:
<div class="example"><P>
<PRE>
H1 {
background: white;
padding: 1em 2em;
}
</PRE>
<P> The example above sets a '1em' padding vertically (<span
class="propinst-padding-top">'padding-top'</span> and <span
class="propinst-padding-bottom">'padding-bottom'</span>) and a '2em'
padding horizontally (<span
class="propinst-padding-right">'padding-right'</span> and <span
class="propinst-padding-left">'padding-left'</span>). The 'em' unit is
relative to the element's font size: '1em' is equal to the size of the
font in use.
</div>
<H3><a name="border-properties">Border properties</a></H3>
<P>The border properties set the borders of an element. Each element
has four borders, one on each side, that are defined by their width,
color and style.
<H4><a name="border-width">Border width</A>: <span
class="propinst-border-top-width">'border-top-width'</span>, <span
class="propinst-border-right-width">'border-right-width'</span>, <span
class="propinst-border-bottom-width">'border-bottom-width'</span>,
<span class="propinst-border-left-width">'border-left-width'</span>, and
<span class="propinst-border-width">'border-width'</span></H4>
<H5><a name="border-width-defs">Values for </a><span class="index-def"
title="&lt;border-width&gt;, definition of"><a
name="value-def-border-width"
class="value-def">&lt;border-width&gt;</a></span></H5>
<P>The properties defined in this section refer to the
<span class="value-inst-border-width">&lt;border-width&gt;</span>
value type, whose possible values may be:
<ul>
<li> 'thin' | 'medium' | 'thick' |
<span class="value-inst-length">&lt;length&gt;</span></li>
</ul>
<P>The interpretation of the first three values depends on the user agent. The following must hold, however:
<P>'thin' &lt;='medium' &lt;= 'thick'.
<P>Furthermore, these widths must be constant throughout a document.
<P> Border widths cannot be negative.
<!-- #include src=properties/border-top-width.srb -->
<P> This property sets the width of an element's top border.
<div class="example"><P>
<PRE>
H1 { border: solid thick red }
P { border: solid thick blue }
</PRE>
<P> In the example above, H1 and P elements will have the same
border width regardless of font size. To achieve relative widths, the
'em' unit can be used:
<PRE>
H1 { border: solid 0.5em }
</PRE>
</div>
<!-- #include src=properties/border-right-width.srb -->
<P> This property sets the width of an element's right
border.
<!-- #include src=properties/border-bottom-width.srb -->
<P> This property sets the width of an element's bottom border.
<!-- #include src=properties/border-left-width.srb -->
<P> This property sets the width of an element's left border.
<!-- #include src=properties/border-width.srb -->
<P> This property is a shorthand property for setting
<span class="propinst-border-top-width">'border-top-width'</span>,
<span class="propinst-border-right-width">'border-right-width'</span>,
<span class="propinst-border-bottom-width">'border-bottom-width'</span>,
and
<span class="propinst-border-width-left">'border-left-width'</span> at
the same place in the style sheet.
<P> There can be from one to four values, with the following
interpretation:
<UL>
<LI>
one value: all four border widths are set to that value
<LI>
two values: top and bottom border widths are set to the first
value, right and left are set to the second
<LI>
three values: top is set to the first, right and left are set to
the second, bottom is set to the third
<LI>
four values: top, right, bottom and left, respectively
</UL>
<div class="example"><P>
In the examples below, the comments indicate the resulting widths
of the top, right, bottom and left borders:
<PRE>
H1 { border-width: thin } /* thin thin thin thin */
H1 { border-width: thin thick } /* thin thick thin thick */
H1 { border-width: thin thick medium } /* thin thick medium thick */
</PRE>
</div>
<H4><A NAME="border-color">Border color</A>:
<span class="propinst-border-top-color">'border-top-color'</span>,
<span class="propinst-border-right-color">'border-right-color'</span>,
<span class="propinst-border-bottom-color">'border-bottom-color'</span>,
<span class="propinst-border-left-color">'border-left-color'</span>, and
<span class="propinst-border-left">'border-color'</span>
</H4>
<!-- #include src=properties/border-top-color.srb -->
<!-- #include src=properties/border-right-color.srb -->
<!-- #include src=properties/border-bottom-color.srb -->
<!-- #include src=properties/border-left-color.srb -->
<!-- #include src=properties/border-color.srb -->
<P>The <span class="propinst-border-color">'border-color'</span>
property sets the color of the four borders. <span
class="propinst-border-color">'border-color'</span> can have from one
to four values, and the values are set on the different sides as for
<span class="propinst-border-width">'border-width'</span> above.
<P> If no color value is specified, the value of the <span
class="propinst-color">'color'</span> property of the element itself
will take its place:
<div class="example"><P>
<PRE>
P {
color: black;
background: white;
border: solid;
}
</PRE>
<P> In the above example, the border will be a solid black line.
</div>
<H4><A NAME="border-style">Border style</a>:
<span class="propinst-border-top-style">'border-top-style'</span>,
<span class="propinst-border-right-style">'border-right-style'</span>,
<span class="propinst-border-bottom-style">'border-bottom-style'</span>,
<span class="propinst-border-left-style">'border-left-style'</span>, and
<span class="propinst-border-style">'border-style'</span></H4>
<H5><a name="border-style-defs">Values for</a> <span class="index-def"
title="&lt;border-style&gt;">&lt;border-style&gt;</span></H5>
<P>The border style properties refer to the &lt;border-style&gt; value
type which is defined as follows:
<UL>
<LI>none | dotted | dashed | solid | double | groove | ridge | inset |
outset
</UL>
<!-- #include src=properties/border-top-style.srb -->
<!-- #include src=properties/border-right-style.srb -->
<!-- #include src=properties/border-bottom-style.srb -->
<!-- #include src=properties/border-left-style.srb -->
<!-- #include src=properties/border-style.srb -->
<P> The <span class="propinst-border-style">'border-style'</span> property sets the style of the
four borders. It can have from one to four values, and the values are
set on the different sides as for <span class="propinst-border-width">'border-width'</span> above.
<div class="example"><P>
<PRE>
#xy34 { border-style: solid dotted }
</PRE>
<P> In the above example, the horizontal borders will be 'solid' and
the vertical borders will be 'dotted'.
</div>
<P> Since the initial value of the border styles is 'none', no borders
will be visible unless the border style is set.
<P>
The border styles mean:
<DL>
<DT>
none
<DD>
no border is drawn (regardless of the <span
class="propinst-border-width">'border-width'</span> property's value)
<DT>
dotted
<DD>
the border is a dotted line drawn on top of the background of the element
<DT>
dashed
<DD>
the border is a dashed line drawn on top of the background of the element
<DT>
solid
<DD>
the border is a solid line
<DT>
double
<DD>
the border is a double line drawn on top of the background of the element.
The sum of the two single lines and the space between equals the
value of <span class="propinst-border-width">'border-width'</span>.
<DT>
groove
<DD>
a 3D groove is drawn in colors based on the value of the <span
class="propinst-color">'color'</span> property.
<DT>
ridge
<DD>
a 3D ridge is drawn in colors based on the value of the <span
class="propinst-color">'color'</span> property.
<DT>
inset
<DD>
a 3D inset is drawn in colors based on the value of the <span
class="propinst-color">'color'</span> property.
<DT>
outset
<DD>
a 3D outset is drawn in colors based on the value of the <span
class="propinst-color">'color'</span> property.
</DL>
<P>UAs may interpret all of 'dotted', 'dashed', 'double',
'groove', 'ridge', 'inset' and 'outset' as 'solid'. See the section on <a
href="convent.html#conformance">conformance</a> for details.
<span class="propinst-border-top">'border-top'</span>,
<span class="propinst-border-bottom">'border-bottom'</span>,
<span class="propinst-border-right">'border-right'</span>,
<span class="propinst-border-left">'border-left'</span>, and
<span class="propinst-border">'border'</span>
<!-- #include src=properties/border-top.srb -->
<P> This is a shorthand property for setting the width, style and
color of an element's top border.
<div class="example"><P>
<PRE>
H1 { border-bottom: thick solid red }
</PRE>
<P> The above rule will set the width, style and color of the border
<strong>below</strong> the H1 element. Omitted values will be set to
their initial values:
<PRE>
H1 { border-bottom: thick solid }
</PRE>
<P> Since the color value is omitted in the example above, the border
color will be the same as the 'color' value of the element itself.
</div>
<P> Note that while the <span
class="propinst-border-style">'border-style'</span> property accepts
up to four values, this property only accepts one style value.
<!-- #include src=properties/border-bottom.srb -->
<P> This is a shorthand property for setting the width, style and
color of an element's bottom border. It behaves just like <span
class="propinst-border-top">'border-top'</span>.
<!-- #include src=properties/border-right.srb -->
<P> This is a shorthand property for setting the width, style and
color of an element's right border. It behaves just like <span
class="propinst-border-top">'border-top'</span>.
<!-- #include src=properties/border-left.srb -->
<P> This is a shorthand property for setting the width, style and
color of an element's left border. It behaves just like <span
class="propinst-border-top">'border-top'</span>.
<!-- #include src=properties/border.srb -->
<P> The <span class="propinst-border">'border'</span>
property is a shorthand property for setting the same width, color and
style on all four borders of an element.
<P> Unlike the shorthand <span class="propinst-margin">'margin'</span> and <span class="propinst-padding">'padding'</span> properties, the <span
class="propinst-border">'border'</span> property cannot
set different values on the four borders. To do so, one or more of the
other border properties must be used.
<P> Note that while the <span class="propinst-border-width">'border-width'</span> property accepts up to four
length values, this property only accepts one.
<div class="example"><P>
For example, the first rule below is
equivalent to the set of four rules shown after it:
<PRE>
P { border: solid red }
P {
border-top: solid red;
border-right: solid red;
border-bottom: solid red;
border-left: solid red
}
</PRE>
</div>
<P> Since to some extent the properties have overlapping
functionality, the order in which the rules are specified becomes
important.
<div class="example"><P>
Consider this example:
<PRE>
BLOCKQUOTE {
border-color: red;
border-left: double
color: black;
}
</PRE>
<P> In the above example, the color of the left border will be black,
while the other borders are red. This is due to <span
class="propinst-border-left">'border-left'</span> setting the
width, style and color. Since the color value is not given by the
<span class="propinst-border-left">'border-left'</span> property, it
will be taken from the <span class="propinst-color">'color'</span>
property. The fact that the <span
class="propinst-color">'color'</span> property is set after the <span
class="propinst-border-left">'border-left'</span> property is not
relevant.
</div>
<H2><a name="box-width">Box width calculations</a>: the <span
class="propinst-width">'width'</span> property</H2>
<P>The width of a box generated by an element does not depend on the
width of its children nor on its content -- it is given by the
<span class="propinst-width">'width'</span> property.
<!-- #include src=properties/width.srb -->
<P> This property can be applied to text elements, but it is most
useful with replaced elements such as images.
<P>Negative values for <span class="propinst-width">'width'</span> are
not allowed.
<div class="example"><P>
For example:
<PRE>
IMG.icon { width: 100px }
</PRE>
</div>
<P> If the <span class="propinst-width">'width'</span> and <span
class="propinst-height">'height'</span> of a replaced element are both
'auto', these properties will be set to the intrinsic dimensions of
the element.
<P> See the section on <a href="#scaling">scaling</a> for information about
setting aspect ratios.
<H3>Relationship of width dimensions</H3>
<P><em>See the section on the <a href="flowobj.html#box-model">the box
model</a> for an illustration of box rendering objects.</em>
<P> The width of a block-level element's box is determined by seven
properties: <span class="propinst-margin-left">'margin-left'</span>,
<span class="propinst-border-left">'border-left'</span>, <span
class="propinst-padding-left">'padding-left'</span>, <span
class="propinst-width">'width'</span>, <span
class="propinst-padding-right">'padding-right'</span>, <span
class="propinst-border-right">'border-right'</span>, and <span
class="propinst-margin-right">'margin-right'</span>.
<P>For elements in the flow, the sum of these seven is equal to the
content <span class="propinst-width">'width'</span> of the parent
element.
<P> If 'auto' is set as the value for one of the seven properties in
an element that is inline or floating, it will be treated as if it
were set to zero.
<P>Horizontal margins are not collapsed.
<H3><a name="replaced-width">Width of floats and replaced elements</a></H3>
<P>For floats and replaced elements (i.e., block-level or inline
elements whose markup is replaced by other content such as the IMG
element in HTML), the calculation of width is as follows:
<P> Three of the seven properties given above can be set to 'auto': <span
class="propinst-margin-left">'margin-left'</span>, <span
class="propinst-width">'width'</span>, and <span
class="propinst-margin-right">'margin-right'</span>. For replaced
elements, a value of 'auto' on <span
class="propinst-width">'width'</span> is replaced by the intrinsic
width, so for them there can only be two 'auto' values.
<P> If <EM>exactly one</EM> of <span
class="propinst-margin-left">'margin-left'</span>, <span
class="propinst-width">'width'</span>, or <span
class="propinst-margin-right">'margin-right'</span> is 'auto', the UA
will assign that property a value that will make the sum of the seven
equal to the parent's width.
<P> If <EM>none</EM> of the properties have the value 'auto', the
value of <span class="propinst-margin-right">'margin-right'</span>
will be assigned 'auto'.
<P> If <EM>more than one</EM> of the three is 'auto', and one of them
is <span class="propinst-width">'width'</span>, then the others (<span
class="propinst-margin-left">'margin-left'</span> and/or <span
class="propinst-margin-right">'margin-right'</span>) will be set to
zero and <span class="propinst-width">'width'</span> will get the
value needed to make the sum of the seven equal to the parent's width.
<P> Otherwise, if both <span
class="propinst-margin-left">'margin-left'</span> and <span
class="propinst-margin-right">'margin-right'</span> are 'auto', they
will be set to equal values. This will center the element inside its
parent.
<H3>Width of absolutely positioned elements</H3>
<P>The width of an absolutely positioned element's box is specified
with the <span class="propinst-width">'width'</span> property.
<P>However, if the <span class="propinst-width">'width'</span> has the
value 'auto', the width of the box is given by the <span
class="propinst-left">'left'</span> and <span
class="propinst-right">'right'</span> properties. Note that these take
the place of the <span
class="propinst-left-margin">'left-margin'</span> and <span
class="propinst-right-margin">'right-margin'</span> properties, which
don't apply to absolutely positioned elements.
<P>If all three properties have the value 'auto', the box has
exactly the width of the inherited reference box.
<H3>Minimum and maximum widths: <span
class="propinst-min-width">'min-width'</span> and <span
class="propinst-max-width">'max-width'</span></h3>
<P>It is sometimes useful to constrain the width of elements to a
certain range. Two properties offer this functionality:
<!-- #include src=properties/min-width.srb -->
<!-- #include src=properties/max-width.srb -->
<P>This algorithm describes how the two properties influence the width
calculations:
<OL>
<LI>the normal width calculations (without 'min-width' and 'max-width')
are performed and the calculated width is found
<LI>if the value of 'min-width' is greater than the value of
'max-width', 'max-width' should be set to the value of 'min-width'
<LI>if the calculated width is greater than 'max-width', the
value of 'width' is set to 'max-width'. Goto step 1.
<LI>if the calculated width is smaller than 'min-width', the
value of 'width' is set to 'min-width'. Goto step 1.
<LI>terminate
</OL>
<P>When the algorithm terminates, use the calculated width as the
width of the element.
<!--
The <span class="propinst-width">'width'</span> has a
non-negative UA-defined minimum value (which may vary from element to
element and even depend on other properties).
<P>A style sheet may add an additional constraint on the Users may override the UA-defined value with the following
property.
<P>If <span class="propinst-width">'width'</span> goes below the minimum
width, either because it was set explicitly, or because it was 'auto'
and the box width calculations would make it too small, the value will
be replaced with the minimum value instead.
<P>Similarly, if an element's <span
class="propinst-width">'width'</span> goes beyond the width of its
parent or reference box, either because it was set explicitly,
or because it was 'auto' and the box width calculations would make it
too large, the value will be replaced by either the width of the
parent or reference box, or the value set by <span
class="propinst-max-width">'max-width'</span>, whichever is smaller.
-->
<H2><a name="box-height">Box height calculations</a>: the <span
class="propinst-height">'height'</span> property</H2>
<P>The height of a box is the minimal height necessary to include the
vertical content of the element and that of all its flowed children
(see also the section on <a href="#minimum-heights">minimum and
maximum heights</a>). This is the height necessary <em>before</em> any
relative offset of children.
<P>However, the height of an element may be set explicitly with
the <span class="propinst-height">'height'</span> property.
<!-- #include src=properties/height.srb -->
<P> This property can be applied to text, but it is most useful with
replaced elements such as images.
<div class="example"><P>
<PRE>
IMG.icon { height: 100px }
</PRE>
</div>
<P> If the <span class="propinst-width">'width'</span> and <span
class="propinst-height">'height'</span> of a replaced element are both
'auto', these properties will be set to the intrinsic dimensions of
the element.
<P> If applied to a textual element, the height can be enforced by the
user interface (e.g., a scrollbar).
<P> Negative values for <span class="propinst-height">'height'</span>
are not allowed.
<P> See the section on <a href="#scaling">scaling</a> for information about
setting aspect ratios.
<!-- Ian: Is this true??? -->
<P>User agents may ignore the
<span class="propinst-height">'height'</span> property (i.e., treat it
as 'auto') if the element is not a replaced element.
<H3>Height of replaced elements</H3>
<P>The height of a replaced element is calculated in a way analogous
to the calculation of the <a href="#replaced-width">width of a
replaced element</a>.
<H3>Height of absolutely positioned elements</H3>
<P>The height of an absolutely positioned element's box is specified
with the <span class="propinst-height">'height'</span> property. A
percentage value for the <span class="propinst-height">'height'</span>
property is computed with respect to the height of the parent
element. However, specifying a percentage value for <span
class="propinst-height">'height'</span> when the parent element's height
is set to 'auto' results in undefined behavior.
<P>If the <span class="propinst-width">'height'</span> has the
value 'auto', the height of the box is given by the <span
class="propinst-top">'top'</span> and <span
class="propinst-bottom">'bottom'</span> properties. Note that these take
the place of the <span
class="propinst-top-margin">'top-margin'</span> and <span
class="propinst-bottom-margin">'bottom-margin'</span> properties, which
don't apply to absolutely positioned elements.
<P>If all three properties have the value 'auto', the box has
exactly the height of the inherited reference box.
<H3><a name="minimum-heights">Minimum and maximum heights</a>: <span
class="propinst-min-height">'min-height'</span> and <span
class="propinst-max-height">'max-height'</span></h3>
<P>It is sometimes useful to constrain the height of elements to a
certain range. Two properties offer this functionality:
<!-- #include src=properties/min-height.srb -->
<!-- #include src=properties/max-height.srb -->
<P>This algorithm describes how the two properties influence the height
calculations:
<OL>
<LI>the normal height calculations (without 'min-height' and 'max-height')
are performed and the calculated height is found
<LI>if the value of 'min-height' is greater than the value of
'max-height', 'max-height' should be set to the value of 'min-height'
<LI>if the calculated height is greater than 'max-height', the
value of 'height' is set to 'max-height'. Goto step 1.
<LI>if the calculated height is smaller than 'min-height', the
value of 'height' is set to 'min-height'. Goto step 1.
<LI>terminate
</OL>
<P>When the algorithm terminates, use the calculated height as the
height of the element.
<!--
<P>If <span class="propinst-height">'height'</span> goes below the minimum
height, either because it was set explicitly, or because it was 'auto'
and the box height calculations would make it too small, the value will
be replaced with the minimum value instead.
<P>Similarly, if an element's <span
class="propinst-height">'height'</span> goes beyond the height of its
parent or reference box, either because it was set explicitly,
or because it was 'auto' and the box height calculations would make it
too large, the value will be replaced by either the height of the
parent or reference box, or the value set by <span
class="propinst-max-height">'max-height'</span>, whichever is smaller.
-->
<H3><a name="collapsing-margins">Collapsing margins</a></H3>
<P> Two or more adjoining vertical margins (i.e., with no border,
padding or content between them) are collapsed to use the maximum of
the margin values. In most cases, after collapsing the vertical
margins the result is visually more pleasing and closer to what the
designer exp 9E70 ects. Please consult the <a
href="./flowobj.html#mpb-examples">examples of margin, padding, and
borders</a> for an illustration of collapsed margins.
<P> In the case of negative margins, the absolute maximum of the
negative adjoining margins is deducted from the maximum of the
positive adjoining margins. If there are no positive margins, the
absolute maximum of the negative adjoining margins is deducted from
zero.
<H2><a name="scaling">Scaling</a></h2>
<P>If necessary, user agents may enforce an element's width and height
by scaling it. When scaling, the aspect ratio of the image is
preserved if values for the <span
class="propinst-width">'width'</span> and <span
class="propinst-height">'height'</span> properties are set to 'auto'.
<P>Authors may also specify a different aspect ratio that should be
preserved in scaling with the following property.
<H2><a name="line-height">Line height calculations</a>: the <span
class="propinst-line-height">'line-height'</span> and <span
class="propinst-vertical-align">'vertical-align'</span>
properties</H2>
<P>As described in the section on <a href="flowobj.html#inline">inline
layout</a>, user agents flow inline boxes horizontally into a series
of line boxes. Each line box is a rectangle whose width is defined by
the first enclosing block element (see the section on <a
href="flowobj2.html#box-width">box width calculations</a>)
<P>The line box height is determined as follows. All elements have the
<span class="propinst-line-height">'line-height'</span> property,
which has the following meaning:
<ul>
<li>If the property is set on a block-level element, it
specifies the <em>minimal</em> line height for all lines of text
generated by the element.
<li>If the property is set on an inline element, it
specifies the <em>exact</em> line height for the element's inline box.
</ul>
<p>Since several inline elements may generate inline boxes on the same
line, the final height of a given line box is the maximum of the
minimal line height specified for the parent block-level element and
the heights required by all inline boxes on the current line. Replaced
elements that create inline boxes (e.g., inline images) also affect
the line height, but via the <span
class="propinst-height">'height'</span> and <span
class="propinst-vertical-align">'vertical-align'</span> properties,
not the <span class="propinst-line-height">'line-height'</span>
property. Replaced elements increase the line box height if the top of
the replaced element (i.e., including all of its padding, border and
margin) is above the tallest text section, or if the bottom is below
the lowest.
<P>When text on a line is smaller than the line box height, space may
be added above and below the text. For example, if the text is 12pt
high and the current line height is '14pt', 2pts of extra space is
added, namely 1pt above and 1pt below the line. Empty elements
influence these calculations just like elements with content.
<P>The difference between the font size and the line height is called
the <span class="index-def"
title="leading"><EM>leading</EM></span>. Half the leading is called
the <span class="index-def"
title="half-leading"><EM>half-leading</EM></span>. If a line of text
contains inline elements with different <span
class="propinst-line-height">'line-height'</span> values, then each
inline element has its own half-leading above and below.
<P>Note that the top and bottom of a line box do not necessarily
correspond to the tallest element, since elements can be positioned
vertically with the <span
class="propinst-vertical-align">'vertical-align'</span> property.
<!-- Give an example/drawing-->
<P>Padding, borders, or margins above and below non-replaced inline
elements do not influence the height of the line. In other words: if
the <span class="propinst-line-height">'line-height'</span> is too
small for the chosen padding or border, it will overlap with text on
other lines.
<P> In the normal case, when there is only one value of <span
class="propinst-line-height">'line-height'</span> throughout a
paragraph, and no tall images, the above definition will ensure that
baselines of successive lines are exactly <span
class="propinst-line-height">'line-height'</span> apart. This is
important when columns of text in different fonts have to be aligned,
for example in a table.
<P> Note that this doesn't prevent text on two adjacent lines from
overlapping. The <span
class="propinst-line-height">'line-height'</span> may be smaller than
the height of the text, in which case the leading will be
negative. This is useful if you know that the text will contain no
descenders (e.g., because it only contains uppercase), so the lines
can be put closer together.
<!-- #include src=properties/line-height.srb -->
<P> The property sets the distance between the baselines
of two adjacent lines.
<P> When a <span class="value-inst-number">&lt;number&gt;</span>, the
line height is given by the font size of the current element
multiplied by the <span
class="value-inst-number">&lt;number&gt;</span>. This differs from a
<span class="value-inst-percentage">&lt;percentage&gt;</span> value in
the way it inherits: when a <span
class="value-inst-number">&lt;number&gt;</span> value is specified,
child elements will inherit the factor itself, not the resultant value
(as is the case with <span
class="value-inst-percentage">&lt;percentage&gt;</span> and other
units).
<P> Negative values are not allowed.
<div class="example"><P>
The three rules in the example below have the same resultant line height:
<PRE>
DIV { line-height: 1.2; font-size: 10pt } /* number */
DIV { line-height: 1.2em; font-size: 10pt } /* length */
DIV { line-height: 120%; font-size: 10pt } /* percentage */
</PRE>
</div>