从< h4>删除非破坏性空格 [英] Remove non breaking space from <h4>

查看:101
本文介绍了从< h4>删除非破坏性空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< h4> 标签的正文内容之前出现一个不间断的空格:

A non-breaking space is appearing inside a <h4> tag, just before the text content:

在我的html中,标签和第一个单词之间有一个空格,但是这不应该只是折叠吗?

In my html, there is a space between the tag and the first word, but should this not just collapse?

<h4> Sed do eiusmod tempor incididut </h4>

在Chrome开发工具中检查元素时,不间断空格实体显示

When inspecting the element in Chrome dev tools, the non-breaking space entity shows:

我没有对此元素应用任何空格css规则。我从来没有见过这个。它表现为< h4> 标记包裹在< pre> 标记...


I have not applied any whitespace css rule to this element. I have never seen this before. It behaves as though the <h4> tag is wrapped in a <pre> tag...

推荐答案

符合这些症状的唯一问题是您的源文件中有一个不间断的空间

The only problem that fits these symptoms is that you have a non-breaking space in your source file, which is visually indistinguishable from a regular space. How it might have gotten there is anybody's guess. Perhaps you accidentally hit some key combination that inserted a non-breaking space.

如果你的编辑器允许你检查代码点,将 U + 00A0 )。否则,选择那个小动物并删除它,并将其替换为一个真实的空间。

If your editor allows you to examine the code point, then do so (a non-breaking space would be U+00A0). Otherwise, select that little critter and delete it and replace it with a real space.

没有办法,其他都相等, h4 标记将神奇地不受标准HTML白色空间折叠的影响。人们可以并且应该能够在这样的地方放置空间,或者甚至将文本放在单独的行上。

There is no way, all else being equal, that a space at the beginning of an h4 tag would magically not be subject to standard HTML white space collapsing. People can and should be able to put spaces in places like that, or even put the text on a separate line. It improves readability.

这个问题在理论上也可能是由各种CSS设置引起的,包括边距,文本缩进,:before 规则,空白设置等。然而,这些都不会导致DOM指示存在不间断的空间。唯一可以想到的替代方案是修改元素内容的一些客户端脚本。

This problem could in theory also be caused by various CSS settings, including margins, text-indent, :before rules, white-space settings, and so on. However, none of these would cause the DOM to indicate a non-breaking space is present. The only conceivable alternative is some client-side script that modifies the element content.

这篇关于从&lt; h4&gt;删除非破坏性空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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