line-height property
Specifies the distance between lines of text in a block-level element.
JavaScript page for this property: lineHeight. You can find other example(s) there. |
Possible values:
One of the following values:
A floating point number, the height of the line is the specified number multiplied by the font size of the element. | |||||||
The height of the line in length units. For the supported length units, see the length page. | |||||||
The height of the line is the specified percentage of the font size of the element. | |||||||
Takes the value of this property from the computed style of the parent element. | |||||||
Default. Normal height is used. |
Default: normal.
Example HTML code 1:
This example illustrates the use of the line-height property:
|
||||
<head> <style> .example1 { border: 1px solid blue; font-size: 14px; line-height: 14px; } .example2 { border: 1px solid blue; font-size: 14px; line-height: 20px; } .example3 { border: 1px solid blue; font-size: 14px; line-height: 30px; } </style> </head> <body> <div class="example1"> Sample multiline text <br />with 14px line-height, font-size is 14px </div> <br /> <div class="example2"> Sample multiline text <br />with 20px line-height, font-size is 14px </div> <br /> <div class="example3"> Sample multiline text <br />with 30px line-height, font-size is 14px </div> </body> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the line-height property, all of the three div elements have the same line height (24px, 120% of 20px, 1.2 * 20px):
|
||||
<head> <style> .example1 { border: 1px solid blue; font-size: 20px; line-height: 24px; } .example2 { border: 1px solid blue; font-size: 20px; line-height: 120%; } .example3 { border: 1px solid blue; font-size: 20px; line-height: 1.2; } </style> </head> <body> <div class="example1"> Sample multiline text <br />with 24px line-height, font-size is 20px </div> <br /> <div class="example2"> Sample multiline text <br />with 120% line-height, font-size is 20px </div> <br /> <div class="example3"> Sample multiline text <br />with 12px line-height, font-size is 20px </div> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by tags:
a, abbr, acronym, address, b, baseFont, bdo, big, blink, blockQuote, body, br, button, caption, center, cite, code, col, colGroup, dd, del, dfn, dir, div, dl, dt, em, fieldSet, font, form, H1, H2, H3, H4, H5, H6, html, i, input:button, input:file, input:password, input:reset, input:search, input:submit, input:text, ins, isIndex, kbd, label, legend, li, listing, marquee, menu, nobr, ol, p, plainText, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tBody, td, textArea, tFoot, th, tHead, tr, tt, u, ul, var, xmp
Related pages:
External links:
line-height (MSDN)
line-height (Mozilla Developer Center)
line-height (Safari Reference Library)
line-height (W3C)
line-height (Mozilla Developer Center)
line-height (Safari Reference Library)
line-height (W3C)
User Contributed Comments