Entities
Entities
Reserved characters in HTML must be replaced with character entities. Characters, not present on your keyboard, can also be replaced by entities.
Character entities are used to display reserved characters in HTML. A character entity looks like this:
&*entity_name*;
OR&#*entity_number*;
The advantage of using an entity name (case sensitive), instead of a number, is that the name is easier to remember. The advantage of using an entity name, instead of a number, is that the name is easier to remember. The disadvantage is that browsers may not support all entity names, but the support for numbers is good.
Non-breaking Space
A common character entity used in HTML is the non-breaking space(不间断空格):   ;
. A non-breaking space is a space that will not break into a new line.
Two words separated by a non-breaking space will stick together at the end of a line. This is handy when breaking the words might be disruptive. For example, 10 m/s, 10 km/h, 10 PM. (防止需要在一起显示的单词被分隔造成理解错误)
Another common use of the non-breaking space is to prevent that browsers truncate spaces in HTML pages. If you write 10 spaces in your text, the browser will remove 9 of them. To add real spaces to your text, you can use the   ;
character entity.(防止浏览器截短空格,10个剩1个,其余9个被删除)
The non-breaking hyphen ‑ ;
(‑) lets you use a hyphen character that won't break.
Combining Diacritical Marks
A diacritical mark(附加符号/变音符号,添加在字幕上面的符号,以改变字母的发音或者区分拼写相似的词语) is a "glyph" added to a letter. Some diacritical marks, like grave ( ̀) (顿音符)and acute ( ́)(尖/重音符) are called accents.
Diacritical marks can appear both above and below a letter, inside a letter, and between two letters.
Diacritical marks can be used in combination with alphanumeric characters, to produce a character that is not present in the character set (encoding) used in the page.
Example:
Mark | Character | Construct | Result |
---|---|---|---|
̀ | a | à | à |
́ | a | á | á |
̂ | a | â | â |
̃ | a | ã | ã |
̀ | O | Ò | Ò |
́ | O | Ó | Ó |
̂ | O | Ô | Ô |
̃ | O | Õ | Õ |