How to Truncate text with CSS

Brief explanation and some code samples:

If the text is longer than one line, it will be truncated and end with an ellipsis ….

HTML

<p class="truncate-text">If I exceed one line's width, I will be truncated.</p>

CSS

.truncate-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  width: 200px;
}

Happy Coding!