white-space



значения свойства:


  • normal
  • nowrap
  • pre
  • pre-line
  • pre-wrap
  • inherit



css/style.css
  • div {
  •  width: 300px;
  •  height: 70px;
  •  border: 1px solid #8E8E8E;
  • }
  •  
  • .a {
  •  white-space: normal;
  • }
  •  
  • .c {
  •  white-space: pre;
  • }
div {
 width: 300px;
 height: 70px;
 border: 1px solid #8E8E8E;
}

.a {
 white-space: normal;
}

.c {
 white-space: pre;
}


index.html
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <link href="css/style.css" rel="stylesheet" />
  •  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  • </head>
  • <body>
  •  <div class="a">
  •   I was dreaming about Hawaii. I was dreaming about my holiday. In
  •   my dream, I was on the beach in Hawaii.
  •  </div>
  •  <br />
  •  <div id="div1">
  •   I was dreaming about Hawaii. I was dreaming about my holiday. In
  •   my dream, I was on the beach in Hawaii.
  •  </div>
  •  <br />
  •  <div class="b">
  •   I was dreaming about Hawaii. I was dreaming about my holiday.<br /> In
  •   my dream, I was on the beach in Hawaii.
  •  </div>
  •  <br />
  •  <div class="c">
  • Hello
  •     World!
  •  </div>
  •  <br />
  • <script>
  •  /*JavaScript*/
  •  document.getElementById("div1").style.whiteSpace = "nowrap";
  •  /*jQuery*/
  •  $(document).ready(function () {
  •   $(".b").css({ "white-space": "nowrap" });
  •  });
  • </script>
  • </body>
  • </html>
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <link href="css/style.css" rel="stylesheet" />
  •  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  • </head>
  • <body>
  •  <div class="a">
  •   I was dreaming about Hawaii. I was dreaming about my holiday. In
  •   my dream, I was on the beach in Hawaii.
  •  </div>
  •  <br />
  •  <div id="div1">
  •   I was dreaming about Hawaii. I was dreaming about my holiday. In
  •   my dream, I was on the beach in Hawaii.
  •  </div>
  •  <br />
  •  <div class="b">
  •   I was dreaming about Hawaii. I was dreaming about my holiday.<br /> In
  •   my dream, I was on the beach in Hawaii.
  •  </div>
  •  <br />
  •  <div class="c">
  • Hello
  •     World!
  •  </div>
  •  <br />
  • <script>
  •  /*JavaScript*/
  •  document.getElementById("div1").style.whiteSpace = "nowrap";
  •  /*jQuery*/
  •  $(document).ready(function () {
  •   $(".b").css({ "white-space": "nowrap" });
  •  });
  • </script>
  • </body>
  • </html>