How to turn off word wrapping in HTML?

后端 未结 6 1698
失恋的感觉
失恋的感觉 2020-11-27 09:24

I feel silly for not being able to figure this out, but how do I turn off wordwrap? the css word-wrap property can be forced on with break-word, bu

6条回答
  •  一个人的身影
    2020-11-27 09:59

    If you want a HTML only solution, we can just use the pre tag. It defines "preformatted text" which means that it does not format word-wrapping. Here is a quick example to explain:

    div {
        width: 200px;
        height: 200px;
        padding: 20px;
        background: #adf;
    }
    pre {
        width: 200px;
        height: 200px;
        padding: 20px;
        font: inherit;
        background: #fda;
    }
    Look at this, this text is very neat, isn't it? But it's not quite what we want, though, is it? This text shouldn't be here! It should be all the way over there! What can we do?
    The pre tag has come to the rescue! Yay! However, we apologise in advance for any horizontal scrollbars that may be caused. If you need support, please raise a support ticket.

提交回复
热议问题