There are two primary methods of generating a character with HTML entities: that is, two ways of generating characters that your keyboard and/or a word processor does not produce by default. Both methods start with an ampersand character (&) and end with a semi-colon. They are keyword and decimal entities.
有两种使用HTML实体生成字符的主要方法:即,两种默认情况下键盘和/或文字处理器不会生成的字符生成方法。 两种方法都以&字符开头,以分号结尾。 它们是关键字和十进制实体。
关键字实体 (Keyword entities)
Keyword entities cover the most common characters, and are recognized by the majority of browsers. A few examples:
关键字实体涵盖了最常见的字符,并且被大多数浏览器所识别。 一些例子:
Keyword | Meaning | Produces |
---|---|---|
© | copyright symbol | © |
™ | trademark symbol | ™ |
° | degree | ° |
— | a long dash – to separate two conjoined pieces of text | – |
– | a short dash or hyphen - to join words or dates (e.g. 1939-45) | – |
“ | a leading quotation mark | “ |
” | a closing quotation mark | ” |
″ | inches, seconds | ″ |
′ | feet, minutes | ′ |
¾ | three-quarters | ¾ |
关键词 | 含义 | 产生 |
---|---|---|
© | 版权符号 | © |
™ | 商标符号 | ™ |
° | 度 | ° |
— | 一个长破折号–分隔两个相连的文本 | – |
– | 短破折号或连字符-连接单词或日期(例如1939-45) | – |
“ | 前导引号 | “ |
” | 右引号 | ” |
″ | 英寸,秒 | '' |
′ | 英尺,分钟 | ′ |
¾ | 四分之三 | ¾ |
十进制实体 (Decimal entities)
Not every character has a keyword entity: the number of possible characters and symbols from every language is simply too great. Every character is also given a decimal entity: a code written in numbers. Sometimes these have keyword entity equivalents, but often not. Successful glyph representation is often more sensitive to font, browser, and OS selection. A minute sampling:
并非每个字符都有一个关键字实体:每种语言可能包含的字符和符号的数量太多了。 每个字符还具有一个十进制实体:用数字编写的代码。 有时这些具有关键字实体等效项,但通常没有。 成功的字形表示通常对字体,浏览器和OS选择更为敏感。 一分钟采样:
Code | Meaning | Produces |
---|---|---|
↺ | open circle clockwise arrow | ↺ |
⇨ | right white arrow | ⇨ |
⅗ | vulgar fraction, three-fifths | ⅗ |
№ | numero sign | № |
Ω | ohm | Ω |
码 | 含义 | 产生 |
---|---|---|
↺ | 空心圆顺时针箭头 | ↺ |
⇨ | 右白色箭头 | ⇨ |
⅗ | 低俗分数,五分之三 | ⅗ |
№ | 数字符号 | № |
Ω | 欧姆 | Ω |
一些奇怪的地方 (A few oddities)
There are a few characters that remain problematic. The first two are the greater and less than sign: when you use < or > in a web page, the browser will assume that you are starting about the start or end of a tag. Use the keyword entities <
and >
to create those.
有些字符仍然有问题。 前两个是大于号和小于号:当您在网页中使用<或>时,浏览器将假定您是从标签的开头或结尾开始的。 使用关键字实体<
和>
创建那些。
The last is the ampersand character, for similar reasons: if you have an & in your document, the browser assumes you are about to start an HTML entity. You have a keyword entity for that too: &
出于相似的原因,最后一个是&字符:如果文档中有&,浏览器会假定您将要启动HTML实体。 您也有一个关键字实体: &
资源资源 (Resources)
There are many good resources for HTML entities and Unicode characters:
有关HTML实体和Unicode字符的好资源很多:
EntityCode is a useful resource for common entities, as is nice entity.
EntityCode是常见的实体有用的资源,如漂亮的实体 。
The FileFormat.info site has an exhaustive list of Unicode characters, including everything you would never want to know about them.
FileFormat.info网站上有Unicode字符的详尽列表,包括您永远不希望了解的所有字符。
Dan Short also has an excellent list of popular graphical HTML entities.
丹·肖特(Dan Short)也列出了流行HTML图形实体 。
If you want to go directly to the source, Unicode.org has a massive series of character charts, in PDF, so you can see what a character should be without worrying about fonts or browser compatibility.
如果您想直接访问源代码, Unicode.org有大量的PDF字符表系列,因此您可以查看字符应该是什么,而不必担心字体或浏览器的兼容性。
LeftLogic has an HTML Entity Lookup, which is also available as a Dashboard widget for Mac OS X.
LeftLogic具有HTML实体查找,也可以作为Mac OS X的“仪表板”小部件使用。
ShapeCatcher helps you find Unicode glyphs by matching possible characters to your drawn sketches.
ShapeCatcher通过将可能的字符匹配到绘制的草图来帮助您找到Unicode字形。
The Unicode Symbol Map is a browser bookmarklet that helps you find common symbols.
Unicode符号映射是一个浏览器书签,可帮助您查找常见符号。
The excellent Unify by John Holt Ripley has a very good comparison of cross-browser and platform Unicode symbol support.
翻译自: https://thenewcode.com/207/HTML-Entities-and-Unicode-Characters