如何阻止浏览器将单个空格替换为多个空格? [英] How to stop Browser from replacing multiple space by single space?

查看:142
本文介绍了如何阻止浏览器将单个空格替换为多个空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

浏览器正在将单词之间的多个空格替换为html页面中的单个空格.例如,如果我的文本在浏览器中为'AB-DC 3',则其显示为'AB-DC 3'.检查窗口,其中显示2个空格'AB-DC 3'.

Browser is replacing Multiple space between words to the single space in html page. for e.g if my text is 'AB-DC 3' in Browser its showing 'AB-DC 3'. Inspect window its showing 2 spaces 'AB-DC 3'.

您也可以尝试一下.只需检查元素并在任何行检查的单词中添加多个空格.

you can also try out yourself. just inspect element and add multiple spaces in word of any line check.

对此有什么解决方案吗? 相似的问题回答了原因,但没有说明如何解决.

is there any solution for this?? Similar question answered cause, but not explaining how to resolve this.

推荐答案

默认情况下,空格不重要,并且在呈现时将其压缩为单个空格.

Whitespace is non-significant by default, and is compacted down to a single space when rendered.

CSS可以更改以下内容:white-space: pre-wrap将提供您期望的默认换行功能,以及预格式化文本的有效空白行为.两全其美!

CSS can change that: white-space: pre-wrap will provide the default line-wrapping functionality that you would expect, plus the significant-whitespace behaviour of preformatted text. Best of both worlds!

这篇关于如何阻止浏览器将单个空格替换为多个空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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