Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在html中保留空白_Html_Xaml - Fatal编程技术网

在html中保留空白

在html中保留空白,html,xaml,Html,Xaml,在xaml中,我可以通过使用标记上的xml:space属性使空白相关(这一点不会被忽略)。参考: 有没有办法使空白在html中变得相关 更新: 最后是: <p style="white-space: pre"> Hi This is an example </p> 嗨,这个 是 一个例子 虽然Aziz shaikh的解决方案也很好。通常的方法是使用不间断的空格,如,用于水平空格,用于换行。不知道我是否正确理解您的问题,但是如果您想在html中保留空

在xaml中,我可以通过使用标记上的xml:space属性使空白相关(这一点不会被忽略)。参考:

有没有办法使空白在html中变得相关

更新:

最后是:

<p style="white-space: pre"> Hi This is an example </p>

嗨,这个 是 一个例子


虽然Aziz shaikh的解决方案也很好。

通常的方法是使用不间断的空格,如
,用于水平空格,

用于换行。

不知道我是否正确理解您的问题,但是如果您想在html中保留空格,pre是您要查找的标签

  <html>
    ....

    <pre>
      hi   this
         is
      an    example
    </pre>
    </html>

....
嗨,这个
是
一个例子
它将为您提供:

<pre style="font:inherit">
    This       is       a
              pre
    test
</pre>
嗨,这个 是 一个例子 您可以将
与css样式一起使用。看看这个

p.foobar { white-space: pre }

<p class="foobar">abc   def</p>

这是一个
之前
测验
您可以在css中指定属性

这与“相关性”无关,而是与浏览器被告知呈现文本的方式有关。
pre
标记在不折叠空白的情况下呈现空白

此渲染属性可以由控制在任何元素上

p.foobar{空白:pre}
abc def


Yes pre是我想要的,除了浏览器上以控制台字体呈现的pre之外。我希望它使用默认字体,但保留空间,就像prejust一样,只需将style属性添加到标记中,您就可以进行任何您想要的样式设置。这样地
p.foobar { white-space: pre }

<p class="foobar">abc   def</p>