Is it possible to make any CSS element behave like <pre>

爱⌒轻易说出口 提交于 2019-12-03 09:17:48

you can find the default setting or how they're suppose to be at http://www.w3.org/TR/CSS2/sample.html just apply the same style to the element you want to behave as a pre element and voila you're done

p.s. which is basically

pre{ white-space: pre ; display: block; unicode-bidi: embed }

If you're only interested in preserving line breaks but not whitespace then I suggest using:

body {
    white-space: pre-line;
}

This will collapse multiple consecutive white space characters into one but preserve line breaks. The downside is that it's only supported in IE versions 8 and up.

Try setting the element's white-space style to a value of pre.

body {
    white-space: pre;
}

If you just want it to act on linebreaks like pre, use the css: white-space: pre

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!