Search code examples
csstextword-wrap

Full word should render in same Line


The full word is not rendering in the same line, it's breaking and rendering in two lines. Please see attached pic(Highlighted part) to better understand the CSS issue. Zip word is rendering in two lines('Zi' in 1st and 'p' in 2nd Line). It should render either in Line 1 or 2. Tried some CSS for "word-wrap" but did not work out. Please help on CSS to fix this issue.

Zip word is rendering in two lines


Solution

  • By default, the word shouldn't break on a new line.

    My guess is that you have a word-break: break-all; style added somewhere. Remove that and it should work

    div {
     border:2px solid red;
     width:40px;
    }
    div.break {
     word-break: break-all;
    }
    <div>
      This is default behavior
    </div>
    <div class="break">
      Here the word breaks
    </div>