HTML CSS Reference/CSS Attributes and Javascript Style Properties/white space

Материал из Web эксперт
Версия от 08:19, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

"white-space" Example

    
<html>
<body>
<div id="myDiv" style="background:beige; width:400px;">
   Line1.<br>
   This sentence has line 1
   line 2
   and    
   <br>
   <br>
   <br>
   <br>
   <br>
   line 3 
   <br>
   This is a regular block of text.
</div>
<br>
<button onclick="myDiv.style.whiteSpace="normal";">Set whiteSpace property to:normal</button>
<button onclick="myDiv.style.whiteSpace="pre";">Set whiteSpace property to: pre</button>
</body>
</html>



"white-space" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |<acronym>                       <address>                     |
|                |<basefont>                      <bdo>                         |
|                |<big>                           <blockquote>                  |
|                |<body>                          <center>                      |
|                |<cite>                          <code>                        |
|                |currentStyle                    <custom>                      |
|                |<dd>                            <dir>                         |
|                |<div>                           <dl>                          |
|                |<dt>                            <em>                          |
|                |<fieldset>                      <font>                        |
|                |<form>                          <hn>                          |
|                |<hr>                            <i>                           |
|                |<ins>                           <isindex>                     |
|                |<kbd>                           <label>                       |
|                |<legend>                        <li>                          |
|                |<listing>                       <menu>                        |
|                |<ol>                            <p>                           |
|                |<pre>                           <q>                           |
|                |<s>                             <small>                       |
|                |<span>                          <strike>                      |
|                |<strong>                        style                         |
|                |<sub>                           <sup>                         |
|                |<tt>                            <u>                           |
|                |<ul>                            <xmp>                         |
+----------------+--------------------------------------------------------------+



"white-space" Possible Values

Possible Values
normal          The default; no extra white space is added.
nowrap          Text wrapping is turned off, line breaks are disabled.
pre             Content wraps to the next line;



"white-space" Syntax and Note

Note:
How to handle white space (line breaks, spaces, tabs). 
Add extra space with one or more &nbsp; 
Add extra lines with the <br> element.
Syntax:
    
element { white-space: value }
elementID.style.whiteSpace = "value"
document.all.elementID.style.whiteSpace = "value" // IE only