line-height property

Sets or retrieves the distance between lines in the object.

CSS 2.1, Section 5.4.8Internet Explorer 9

Syntax

line-height: normal | number | length | percentage | inherit

Property values

normal

Default. Default height.

number

The used value is this number multiplied by the element's font size. Negative values are ignored.

length

Floating-point number, followed by an absolute units designator (cm, mm, in, pt, or pc) or a relative units designator (em, ex, or px). For more information about the supported length units, see CSS Values and Units Reference.

percentage

Integer, followed by a percent sign (%). The value is a percentage of the height of the parent object.

inherit

For a given element, the property takes the same specified value as the property for the element's parent.

CSS information

Applies ToAll elements
Mediavisual
Inheritedno
Initial Valuenormal

Standards information

Remarks

Line height is the distance between the descender of the font and the top of the internal leading of the font.

If a formatted line contains more than one object, the maximum line height applies. In this case, negative values are not allowed.

Microsoft Internet Explorer 3.0 supports the line-height attribute through the font attribute.

Examples

The following examples use the line-height attribute and the line-height property to control the height of paragraph lines.

This example uses p and blockquote as selectors in an embedded (global) style sheet to change the distance between the lines in all p and blockquote objects.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/line-height.htm


<style>
    p { line-height:8mm; }
    blockquote { line-height:4mm; }
</style>

This example uses inline scripting to set the distance between lines when an onmouseover event occurs.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/lineHeight.htm


<div style="font-size: 14pt" onmouseover="this.style.lineHeight='6mm'">
  .
  .
  .
</div>

See also

CSSStyleDeclaration
currentStyle
defaults
runtimeStyle
style

 

 

Show:
© 2014 Microsoft. All rights reserved.