在 HTML 文本的开头显示空格 [英] Show white space at the beginning of a text in HTML

查看:57
本文介绍了在 HTML 文本的开头显示空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 HTML 文本的开头显示空格?

How do I display white space at the beginning of text in HTML?

比如我想用

<p>             This is a paragraph.</p> //             This is a paragraph. 

但它的行为与

<p>This is a paragraph.</p>

我该怎么做?

推荐答案

你可以在 CSS 中使用 white-space: pre; 属性,它不会折叠空格:

You can use white-space: pre; property in CSS which doesn't collapse spaces:

    p {
    	white-space: pre;
    	color: black;
    	background: pink;
    }

    <p>             This is a paragraph.</p>

这篇关于在 HTML 文本的开头显示空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆