There are several correct ways to display a down-pointing triangle.
Method 1 : use decimal HTML entity
Method 2 : use hexidecimal HTML entity
Method 3 : use character directly
Method 4 : use CSS
Each of these three methods should have the same output. For other symbols, the same three options exist. Some even have a fourth option, allowing you to use a string based reference (eg.
♥ to display ♥).
You can use a reference website like Unicode-table.com to find which icons are supported in UNICODE and which codes they correspond with. For example, you find the values for the down-pointing triangle at http://unicode-table.com/en/25BC/.
Note that these methods are sufficient only for icons that are available by default in every browser. For symbols like ☃,❄,★,☂,☭,⎗ or ⎘, this is far less likely to be the case. While it is possible to provide cross-browser support for other UNICODE symbols, the procedure is a bit more complicated.
If you want to know how to add support for less common UNICODE characters, see Create webfont with Unicode Supplementary Multilingual Plane symbols for more info on how to do this.
A totally different strategy is the use of background-images instead of fonts. For optimal performance, it's best to embed the image in your CSS file by base-encoding it, as mentioned by eg. @weasel5i2 and @Obsidian. I would recommend the use of SVG rather than GIF, however, is that's better both for performance and for the sharpness of your symbols.
This following code is the base64 for and SVG version of the icon :
/* size: 0.9kb */
When to use background-images or fonts
For many use cases, SVG-based background images and icon fonts are largely equivalent with regards to performance and flexibility. To decide which to pick, consider the following differences:
- They can have multiple colors
- They can embed their own CSS and/or be styled by the HTML document
- They can be loaded as a seperate file, embedded in CSS AND embedded in HTML
- Each symbol is represented by XML code or base64 code. You cannot use the character directly within your code editor or use an HTML entity
- Multiple uses of the same symbol implies duplication of the symbol when XML code is embedded in the HTML. Duplication is not required when embedding the file in the CSS or loading it as a seperate file
- You can not use
background-color or other font related styling rules to change the display of your icon, but you can reference different components of the icon as shapes individually.
- You need some knowledge of SVG and/or base64 encoding
- Limited or no support in old versions of IE
- An icon can have but one fill color, one background color, etc.
- An icon can be embedded in CSS or HTML. In HTML, you can use the character directly or use an HTML entity to represent it.
- Some symbols can be displayed without the use of a webfont. Most symbols cannot.
- Multiple uses of the same symbol implies duplication of the symbol when your character embedded in the HTML. Duplication is not required when embedding the file in the CSS.
- You can use
background-color or other font related styling rules to change the display of your icon
- You need no special technical knowledge
- Support in all major browsers, including old versions of IE
Personally, I would recommend the use of background-images only when you need multiple colors and those color can't be achieved by means of
background-color and other color-related CSS rules for fonts.
The main benefit of using SVG images is that you can give different components of a symbol their own styling. If you embed your SVG XML code in the HTML document, this is very similar to styling the HTML. This would, however, result in a web page that uses both HTML tags and SVG tags, which could significantly reduce the readability of a webpage. It also adds extra bloat if the symbol is repeated across multiple pages and you need to consider that old versions of IE have no or limited support for SVG.