Why use html entities




















I would not use UTF-8 for characters that are easily confused visually. For example, it is difficult to distinguish an emdash from a minus, or especially a non-breaking space from a space. For these characters, definitely use entities. For characters that are easily understood visually such as the chinese examples above , go ahead and use UTF-8 if you like. Also, if you intend on doing some programming using utf-8 text, there are a few thing to watch for.

HTML entities are useful when you want to generate content that is going to be included dynamically into pages with several different encodings. If your pages are correctly encoded in utf-8 you should have no need for html entities, just use the characters you want directly. In addition: It mostly depends on the editor you intent to use and the document language. As a minimum requirement for the editor is that it supports the document language.

That means, that if your text is in japanese, beware of using an editor which does not show them i. But even with the other latin-1 languages german, french etc.

In addition, I personally write entities for invisible characters and those which are looking similar to standard-ascii and are therefore easily confused. For example, there is u looking like a dash in some charsets or u, which looks like the vertical bar. I'd use entities for those in any case. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?

Collectives on Stack Overflow. Learn more. When should one use HTML entities? Ask Question. Asked 12 years, 9 months ago. Active 2 years, 7 months ago. Viewed 25k times. It will be appreciated. Improve this question. Matthew 8, 11 11 gold badges 57 57 silver badges 80 80 bronze badges.

On a side note, what will htmlentities in PHP do? Reading the answers and comments it seems to me there is not yet a universal rule in favor of one or the other, and the answer still is it depends. Add a comment. Active Oldest Votes. The reasons listed are as follows: UTF-8 encodings are easier to read and edit for those who understand what the character means and know how to type it. UTF-8 encodings are just as unintelligible as HTML entity encodings for those who don't understand them, but they have the advantage of rendering as special characters rather than hard to understand decimal or hex encodings.

The article goes on to say the following about the HTML entity-encoded version: Extremely inconvenient for those of us who actually know what character entities are, totally unintelligible to poor users who don't! Improve this answer. This answer helps tremendously. While plain UTF-8 characters are better for the reasons you've listed, there's no issue still having some HTML entities alongside them in the same document?

Entities can be useful when: Your keyboard does not support the character you need to type. For example, many keyboards do not have em-dash or the copyright symbol. Your editor does not support Unicode very common some years ago, but probably not today. You want to make it explicit in the source what is happening.

Jonathan Leffler k gold badges silver badges bronze badges. JacquesB JacquesB Very helpful. I use a helpful program to get unusual characters.

It's called popchar and is made by Ergonis but is only for OS X. So using the entity in that case is the only way to ensure that the source doesn't get messed up every time a Firefox user edits it.

Two words separated by a non-breaking space will stick together not break into a new line. This is handy when breaking the words might be disruptive.

Another common use of the non-breaking space is to prevent browsers from truncating spaces in HTML pages. If you write 10 spaces in your text, the browser will remove 9 of them.

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. We just launched W3Schools videos. Get certified by completing a course today! If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:. Links Link Colors Link Bookmarks.

Report Error.



0コメント

  • 1000 / 1000