CSS Text Effects with Example

In CSS Text Effects we have following Properties:

  1. text-overflow

  2. word-wrap

  3. word-break

  4. writing-mode


Text-Overflow

The CSS text-overflow property specifies how overflowed content that is not displayed should be signaled to the user.


Code:

<!DOCTYPE html>
<html>
<head>
<style> 
p.test1 {
  white-space: nowrap; 
  width: 200px; 
  border: 1px solid #000000;
  overflow: hidden;
  text-overflow: clip;
}

p.test2 {
  white-space: nowrap; 
  width: 200px; 
  border: 1px solid #000000;
  overflow: hidden;
  text-overflow: ellipsis;
}
</style>
</head>
<body>

<h1>The text-overflow Property</h1>
<p>The following two paragraphs contains a long text that will not fit in the box.</p>

<h2>text-overflow: clip:</h2>
<p class="test1">This is some long text that will not fit in the box</p>

<h2>text-overflow: ellipsis(...):</h2>
<p class="test2">This is some long text that will not fit in the box</p>

</body>
</html>

Output:





Word-Wrap

The CSS word-wrap property allows long words to be able to be broken and wrap onto the next line.


Code: