So, you’ve found a symbol you like, which in this hypothetical case is the “ℹ” symbol, and you want to find the following values:
- The decimal-numeric HTML entity (aka.
&#...;
). - The hexadecimal-numeric CSS
content
value (aka.content: "\..."
).
And, you want to do this without spending the next five minutes searching for the values online… again.
If you’ve set
<meta charset="UTF-8">
in the<head>
of your HTML file, you can just paste “ℹ” into your HTML file (not into the CSScontent
value); HTML entities are optional when using UTF-8.The only exceptions to this are characters like the less-than or greater-than symbols which do require you to use HTML entities.
In-browser method
- Navigate to your browser’s developer tools, which is typically bound to F12.
- Open its terminal (typically behind a tab labelled Console).
- Then, enter one of the following commands:
- For the HTML value, type in:
"ℹ".charCodeAt(0).toString(10)
. - For the CSS value, type in:
"ℹ".charCodeAt(0).toString(16)
.
- For the HTML value, type in:
- Finally, execute the command (usually done with a button labelled Run).
To remove the need to remember both values, consider using the hexadecimal character reference for the HTML entity instead, e.g.
ℹ
(notice the addedx
).
Bonus Linux method
If you know the decimal value already, and want to find the hexadecimal value without using the browser’s terminal, simply run printf “%x” “8505” which will return 2139.