HTML & Character Entity


The & character entity is an HTML prefix for escaping words. It outputs an ampersand and is used as the sigial for escaped characters like <, >, and ", which are special characters that HTML uses to markup a string of text.

Using & correctly is important because it prevents href=”&” from breaking a link and ending the value of that link. This was a big problem before HTML5 standardized the behavior, but it’s now OK to use & as long as what follows is not interpreted as an entity reference.

Note: Using & to curl single and double quotes is not recommended, because this doesn’t comply with all international standards. Instead, use decimal numeric character references for these marks. The glyphs for each character are available from the Unicode Consortium.

Turn special HTML entities into character equivalents with the htmlspecialchars function and convert all other characters back to their original HTML entities with the htmlspecialchars_back() function. This function accepts a bitmask of one or more flags, which specify how to handle quotes and which document type to use (default: ENT_QUOTES). The htmlspecialchars() function also removes HTML tags.


%d bloggers like this: