|HTML & CSS
Tips and Tricks
UNICODE: NICKNAMES OR NUMBERS?
Various bloggers maintain that, when specifying a Unicode
special character, only the numeric code should be used.
My response to that is:
An entity reference, or named character reference
as it is called in HTML5, is a mnemonic equivalent, meaning that
English-speaking person can recognize it for what it is
without having to memorize a number.
There are entity references for more than 1,000 Unicode characters, presumably because they are the ones most commonly used. Virtually every coder utilizes the following four mnemonics a lot, possibly without even thinking of them as such:
In fact, according to my reading, those are the only entity
references that are acceptable in XML documents. If you are
doing any of that, you might as well skip the rest of this page;
otherwise, I daresay that you have occasion to use certain other
non-keyboard characters with some frequency. Which ones
they are will depend upon the typical content of your own pages.
The special character that I use most frequently is the
non-breaking space ( ), mostly
because I learned in grade-school to put two spaces between
my sentences. If I had to type
all the time, I would go mad. Another character that I use
a great deal is the em-dash (—).
When I type in —, I can see what is going
on in my text; whereas the equivalent —
would just clutter the page (and also make me crazy).
These entity references satisfy most mathematical requirements:
|±||±||plus or minus|
|≥||≥||greater than or equal|
|≤||≤||less than or equal|
The invisible soft-hyphen lets a browser
words without otherwise displaying a hyphen on the page:
These are useful for writing such terms as "déjà vu":
There is nothing wrong with using the apostrophe or standard
double-quote character on the keyboard, except that some
applications, particularly word processors, tend to hijack them and
replace them with what they deem to be better-looking
characters. (That is why many web pages and emails have some
utter garbage characters on them even though those functions can be
adjusted in the software settings; but that's another topic.)
These two can "pretty-up" some quotes:
Used myself mostly on hiking journals, these have other uses as well:
|·||·||smaller than a bullet|
Similar nicknames have been established for fifths and sixths;
but those characters are rather
ugly-looking, so I avoid them.
Now, for what it's worth, I would share a mostly forgotten method
that was popular in the days of
MS-DOS. In fact, any of
the printable ascii characters can be displayed on the screen or placed
into a text document simply by holding down an <Alt>
key while typing its ascii value on the numeric keypad!
<Alt>171 will produce the
½-character, and <Alt>172 begets
the ¼-symbol. Although those two numbers were
committed to memory a long time ago, I cannot remember all the ascii
values; so I still use ° for degrees instead of
<Alt>176, and ÷ instead of
<Alt>246 for division.
Of all the symbols listed here, only the
double-arrow are not ascii characters. Using
this method with values greater than 255 will produce unexpected
results. The choice is yours.