浏览器是否删除任何 html 标签文本之间的空格 [英] Do browsers remove whitespace in between text of any html tag

查看:28
本文介绍了浏览器是否删除任何 html 标签文本之间的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个演示问题的小提琴

http://jsfiddle.net/WM8XW/

我在标签标签的内容中插入了许多空格,但呈现的 html 似乎将其删除.添加   是解决上述问题的唯一方法

HTML 内容

解决方案

显示空白的正常行为是将它们压缩成一个,然后显示出来.

有两个例外:

  1. 标签,保留输入的空格.
  2. 设置 CSS 属性 white-space: pre; (分别是pre-wrappre-line)

Here is a fiddle demonstrating the problem

http://jsfiddle.net/WM8XW/

I have inserted many whitespace in the content of the label tag but the html rendered seems to remove it. Is adding   only solution to the above problem

HTML Content

<label>label with very          long white space in between</label>

解决方案

The normal behavior for the display of whitespaces is to compress them into a single one, which is then displayed.

There are two exceptions from that:

  1. The <pre> tag, which keeps the whitespaces as entered.
  2. Setting the CSS property white-space: pre; (respectively pre-wrap or pre-line)

这篇关于浏览器是否删除任何 html 标签文本之间的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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