white-space property
Specifies how spaces, tabs, and newline characters inside the element are handled.
With this property you can manipulate the default line breaking rules.
To add extra line breaks, use the br element.
JavaScript page for this property: whiteSpace. You can find other example(s) there. |
Possible values:
One of the following values:
Prevents user agents from collapsing sequences of whitespace. | |||||||
Takes the value of this property from the computed style of the parent element. | |||||||
Default. Collapses sequences of whitespace, and breaks lines automatically. | |||||||
Collapses sequences of whitespace, but prevents lines from wrapping. | |||||||
Preserves all line breaks and whitespaces. | |||||||
Directs user agents to collapse sequences of whitespace. | |||||||
Prevents user agents from collapsing sequences of whitespace. |
Default: normal.
Example HTML code 1:
This example illustrates the use of the white-space property:
|
||||
<head> <style> .example { width: 200px; overflow: auto; border: 1px solid #FF0000; margin: 10px; } .normal { white-space: normal; } .nowrap { white-space: nowrap; } .pre { white-space: pre; } </style> </head> <body> <div class="example normal"> The white-space property is set to normal.<br /> The white-space property is set to normal.<br /> The white-space property is set to normal.<br /> The white-space property is set to normal. </div> <div class="example nowrap"> The white-space property is set to nowrap.<br /> The white-space property is set to nowrap.<br /> The white-space property is set to nowrap.<br /> The white-space property is set to nowrap. </div> <div class="example pre"> The white-space property is set to pre.<br /> The white-space property is set to pre.<br /> The white-space property is set to pre.<br /> The white-space property is set to pre. </div> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by tags:
a, abbr, acronym, address, b, baseFont, bdo, big, blink, blockQuote, body, button, caption, center, cite, code, 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, tt, u, ul, var, xmp
Related pages:
External links:
white-space (MSDN)
white-space (Mozilla Developer Center)
white-space (Safari Reference Library)
white-space (W3C)
white-space (Mozilla Developer Center)
white-space (Safari Reference Library)
white-space (W3C)
User Contributed Comments