CSS - line-break 屬性



line-break 屬性用於確定如何在一段文字中換行。這非常重要,因為它使頁面更易讀和易於理解。

可能的值

  • auto:應用預設換行規則。

  • loose:應用限制最少的換行規則。

  • normal:應用最常見的換行規則。

  • strict:應用最嚴格的換行規則。

  • anywhere:允許瀏覽器在任何位置、任何字元處應用換行規則。

  • initial:設定初始值。

  • inherit:繼承父元素的值。

應用於

所有 HTML 元素。

DOM 語法

object.style.lineBreak = "strict";

示例

這是一個示例

<html>
<head>
<style>
   p {
      border: 2px solid blue;
      width: 200px;
   }
   .normal {
      line-break: normal;
   }
   .loose {
      line-break: loose;
   }
   .strict {
      line-break: strict;
   }
   .auto {
      line-break: auto;
   }
   .anywhere {
      line-break: anywhere;
   }
</style>
</head>
<body>
   <h2>Line Break</h2>
      <p class="normal">Normal - CSS provides property <b>line-break</b> that is useful in determining how to break lines in a block of text.</p>
      <p class="loose">Loose - CSS provides property <b>line-break</b> that is useful in determining how to break lines in a block of text</p>
      <p class="strict">Strict - CSS provides property <b>line-break</b> that is useful in determining how to break lines in a block of text</p>
      <p class="auto">Auto - CSS provides property <b>line-break</b> that is useful in determining how to break lines in a block of text</p>
      <p class="anywhere">Anywhere - CSS provides property <b>line-break</b> that is useful in determining how to break lines in a block of text</p>
</body>
</html> 
廣告