Auto break line in HTML using CSS

Break line in HTML will make content easier to read when we meet a long word. For example, user comment a long URL and we have to display full URL, but the problem is the area we use for it not too big to display all of long URL. In this case, we need the way to make it break line auto.

break line

Now, let ‘s do a very simple way to solve this problem. Just need to do this CSS

selector {
      word-wrap: break-word;      /* IE 5.5-7 */
      white-space: -moz-pre-wrap; /* Firefox 1.0-2.0 */
      white-space: pre-wrap;      /* current browsers */
}

Very simple, but it work. Hope it will help you guys solve a small task.

One comment

  1. It work like charm, thanks guy. I only think about the URL what need this hack but it ‘s good enough for all of other situations.

Leave a Reply

Your email address will not be published. Required fields are marked *

*