Reputation: 20765
When writing an HTML document, is it acceptable to use the direct special character such as the captial letter C with a cedilla underneath as regular text: Ç
or to use the HTML Entity name of this charecter, Ç
?
I have seen both being used in practice, but surely there are rules governing the appropriate usage of this, as well as advantages to one way over another. For instance, this website maintains the raw-form of this character, but other websites may end up rendering it as a square block.
Upvotes: 4
Views: 5411
Reputation: 22947
It all depends on the character encoding of the document. If you're unsure of whether or not you should use the the regular text or the encoding version, you could run your page through the W3C Validator.
Consider this code:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Stuff</title>
</head>
<body>
<p>©</p>
<p>©</p>
</body>
</html>
The document encoding is set to UTF-8 and when it's validated, it returns an error:
Sorry, I am unable to validate this document because on line 7 it contained one or more bytes that I cannot interpret as utf-8 (in other words, the bytes found are not valid values in the specified Character Encoding). Please check both the content of the file and the character encoding indication.
Upvotes: 2
Reputation: 943571
Real characters:
HTML entities:
Obviously, characters with special meaning in HTML (<
, &
, etc) still need to be represented by entities.
Upvotes: 9
Reputation: 168685
If you're using UTF-8 character encoding, then most entity characters (other than &
, >
and <
) become redundant.
If you're not using UTF-8, then you need entities for everything.
Upvotes: 4