Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
@wingmeng

Description

@wingmeng
Issue body actions

开发中我们有时候会利用一些特殊字符来制作图标,例如 ><+ 等,这类字符都是视觉可见的,我们可以使用 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, '');
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.