css_whitespace.html 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>CSS white-space property</title>
  5. <link rel="Stylesheet" href="http://yui.yahooapis.com/3.3.0/build/cssreset/reset-min.css">
  6. <style>
  7. #wrap { margin:30px auto; width:600px; font-family:sans-serif; color:#444; cursor:default; }
  8. h1 { font-size:40px; text-align:center; font-weight:bold; margin-bottom:30px; text-shadow:0 0 3px #ddd; }
  9. pre { background-color:#eee; margin:10px 0; padding:5px; }
  10. p.demo { background-color:orange; width:100px; margin:10px 0; font-family:monospace; }
  11. </style>
  12. </head>
  13. <body>
  14. <div id="wrap">
  15. <h1>CSS white-space property</h1>
  16. <p> Given this CSS code: </p>
  17. <pre>
  18. p {
  19. width:100px;
  20. background-color:orange;
  21. margin:10px 0;
  22. font-family:monospace;
  23. }
  24. </pre>
  25. <p> and this HTML code: </p>
  26. <pre>
  27. &lt;p&gt;
  28. P
  29. A
  30. R
  31. A
  32. G
  33. R
  34. A
  35. P
  36. H
  37. &lt;/p&gt;
  38. </pre>
  39. <p> Depending on the white-space property, the resulting presentation will be: </p>
  40. <hr>
  41. <p> normal </p>
  42. <p class="demo" style="white-space:normal">
  43. P
  44. A
  45. R
  46. A
  47. G
  48. R
  49. A
  50. P
  51. H
  52. </p>
  53. <hr>
  54. <p> nowrap </p>
  55. <p class="demo" style="white-space:nowrap">
  56. P
  57. A
  58. R
  59. A
  60. G
  61. R
  62. A
  63. P
  64. H
  65. </p>
  66. <hr>
  67. <p> pre </p>
  68. <p class="demo" style="white-space:pre">
  69. P
  70. A
  71. R
  72. A
  73. G
  74. R
  75. A
  76. P
  77. H
  78. </p>
  79. <hr>
  80. <p> pre-wrap </p>
  81. <p class="demo" style="white-space:pre-wrap">
  82. P
  83. A
  84. R
  85. A
  86. G
  87. R
  88. A
  89. P
  90. H
  91. </p>
  92. <hr>
  93. <p> pre-line </p>
  94. <p class="demo" style="white-space:pre-line">
  95. P
  96. A
  97. R
  98. A
  99. G
  100. R
  101. A
  102. P
  103. H
  104. </p>
  105. </div>
  106. </body>
  107. </html>