Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to define custom special characters in HTML? [duplicate]

W3 have defined symbols &mail; and &telephone; in a draft proposal. I'd like to start using those now, even though they're not yet official.

Is there some way I can define this; e.g. &telephone; = ☎?

My guess it it's not possible, and it's not really much of an issue - just curious as being able to create such custom character mappings could be interesting.

http://www.w3.org/TR/WD-wwwicn.html

like image 848
JohnLBevan Avatar asked Mar 02 '13 02:03

JohnLBevan


People also ask

How do you specify Special Characters in HTML?

When you want to insert a special character, select Insert > HTML > Special Characters. From there are you presented with a few of the most common, or you can choose “Other” to view all the characters available. Simply select the character you would like to insert and the code is inserted for you.

Does HTML support Special Characters?

Some characters are reserved in HTML and they have special meaning when used in HTML document. For example, you cannot use the greater than and less than signs or angle brackets within your HTML text because the browser will treat them differently and will try to draw a meaning related to HTML tag.

What is the term used for the Special Characters that you can add to a Web page by using special codes?

HTML Symbol Entities Many mathematical, technical, and currency symbols, are not present on a normal keyboard. To add such symbols to an HTML page, you can use the entity name or the entity number (a decimal or a hexadecimal reference) for the symbol.


1 Answers

it would be really easy to implement this JavaScript.

var el=document.getElementById('element');
el.innerHTML=el.innerHTML.replace(/\&telephone\;/g,'☎').replace(...........

It's a much better idea though to do this on the server side. e.g. in PHP you could use the strreplace($needle,$haystack) function or define a telephone constant.

define('telephone','&#x260e');
//...
echo'<span>',telephone,' 001 23456789</span>';
like image 148
aelgoa Avatar answered Oct 16 '22 23:10

aelgoa