Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第 66 期(W3C 标准-HTML):特殊实体字符HTML、CSS、JS对照表 #69

Open
wingmeng opened this issue Jul 22, 2019 · 0 comments
Open

Comments

@wingmeng
Copy link
Collaborator

开发中我们有时候会利用一些特殊字符来制作图标,例如 ><+ 等,这类字符都是视觉可见的,我们可以使用 Unicode 编码(如 \u3e)、实体字符编码(如 &gt;)甚至直接键入字符的方式来输入字符,但如果在代码中需要插入一些视觉上不可见(或不易区分)的字符呢?例如:

  • 半角空格
  • 全角空格
  • tab
  • 1汉字宽度空格
  • 1/2汉字宽度空格
  • 换行

下面给出一份对照表:

image

应用举例:

<strong>	富&emsp;强</strong>
<strong>	民&emsp;主</strong>
<strong>	文&emsp;明</strong>
<strong>	和&emsp;谐</strong>
/* 文末换行 */
/* 《CSS 揭秘》 P115 */
strong::after {
  content: "\a";
  white-space: pre;
}
// 清除内容中的 tab ko
var words = document.querySelectorAll('strong');

[].slice.call(words).map(function(item) {
  item.innerText = item.innerText.replace(/\t/g, '');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant