Search code examples
htmlcssword-wrap

CSS, words wrap automatically


CSS, words wrap automatically. How to do this?

I want to let words like:

O:
Which is the most horrifying thing/disease you have seen in your medical career?

To:
Which is the most horrifying
thing/disease you have seen
in your medical career?

I am used word-wrap: break-word but display like:

Which is the most horrifying t
hing/disease yo
u have seen in you
r medical career?

Solution

  • One possible solution is, if you want it to be specific width, then you have to define it.
    Example:
    HTML:

    <p>Which is the most horrifying thing/disease you have seen in your medical career?</p>
    


    CSS:

    p {
        width: 200px;
        word-wrap: break-word;
    }