html - 如何在没有 <br> 的情况下显示带有线条的段落

标签 html css

我有一个文本,我想用线条来显示它

像这样没有<br>标签。

例子:

hello.
how are you ?
fine !

不是这样的:

hello. how are you ? fine !

有人可以帮助我吗?

最佳答案

您应该使用pre 标签。与 br 标签相比,这样做的好处之一是它可以编写更少的字符。使用 br,您将不得不使用其中的大约五个。这会导致文件变大。虽然这个差异很小,但它是一个微小的改进。

The HTML pre element defines preformatted text.

The text inside a pre element is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks:

您可以使用 style 属性保留原始样式。根据您想要的字体大小和字体系列,您可以执行类似的操作。

<pre style="font-size: 16px, font-family: Verdana" >hello.
how are you ?
fine !
not like this :
hello. how are you ? fine !
someone can help me ?</pre>

关于html - 如何在没有 <br> 的情况下显示带有线条的段落,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35688203/

相关文章:

jquery - 最后一个 DIV 只能滚动

javascript - 触发更改不会更新 vuejs 绑定(bind)

javascript - 如何使用 jQuery 在悬停时隐藏/显示某些 div?

包含空格的 HTML 类名?

javascript - 使用 Swipe 支持如何将菜单滑回?

html - <table> 具有固定的 <thead> 和可滚动的 <tbody>

php - 带有单选按钮的 Mysql 更新数据库

html - 对齐表格中的图像并添加标题标题行

html - 如何将 Bootstrap 轮播与 div 高度相匹配?

html - HipChat URL 图片预览