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

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

问题描述

这是演示问题的小提琴

http:/ /jsfiddle.net/WM8XW/



我在标签标签的内容中插入了许多空格,但呈现的html似乎将其删除。仅为& nbsp; 添加上述问题的解决方案


$ b HTML内容

 < label>标签的中间有非常长的空格< / label> 


解决方案

显示空格的正常行为是压缩他们成为一个单一的,然后显示。



有两个例外:


  1. < pre> ; 标记,它保持输入的空白​​。

  2. 设置CSS属性 white-space:pre; (分别为 pre-wrap pre-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 &nbsp; 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天全站免登陆