Display element as preformatted text via CSS [duplicate]

て烟熏妆下的殇ゞ 提交于 2019-11-27 18:14:00
BoltClock

Use white-space: pre to preserve whitespace preformatting as in the pre element. To go a step further, also add font-family: monospace, as pre elements are typically set in a monospace font by default (e.g. for use with code blocks).

.preformatted {
    font-family: monospace;
    white-space: pre;
}
<div class="preformatted">

  Please procure the following items:

    - Soup
    - Jam
    - Hyphens 
    - Cantaloupe
</div>
.preformatted {
   white-space: pre-wrap;
}

I think "pre-wrap" is better. It can help with long length in line.

Yes:

div.preformatted {
    white-space: pre;
    }

Reference:

inorder to get <pre> you may use;

div.preformatted{ white-space: pre ; display: block; }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!