How to output & a m p ; (ampersand) as a ampersand?

As you know if you put

&

ampersand it outputs &. I have tried wrapping it in code tags and pre. Neither worked. I have searched but only thing I could find is everyone asking the opposite.

You cannot in normal flow as ampersand character (“&”) declares the beginning of an entity reference so you’d use NCR, i.e.: & and that would render the following: &

Awesome thank you much!

[font=verdana]The easiest way I find is to put an empty tag in the middle, along the lines of [noparse]&[/noparse]. That breaks up the entity and then the forum software doesn’t recognise it and shows it intact.

Off Topic:

Moved to ‘forum support’ section.

What I do is similar to Stevie. I wrap part of the entity with the color black.

Thanks but no need to move it. As this was not for BBcode. It was for some code output on my site. AKA html code.

Gotcha. Even easier than Robert 's way, because it saves you remembering the hex code, is &, which does exactly the same but with named entities.

cool cool good to know. Thanks

NCRs (numeric character references) and ‘character entity references’ are types of character escape used in markup. Getting back to the question NCR is the preferable choice over the entities, entities are limited to a subset of Unicode characters, NCR can specify any character and theoretically Hexadecimal has less ambiguity. NCR for the win. :slight_smile:

NCR as explained are more functional. HTML 4.01 has 252 Character entity references: http://www.w3.org/TR/html401/sgml/entities.html For X(HT)ML an application of XML, we have the XML specification that defines five “predefined entities” only: http://www.w3.org/TR/REC-xml/#sec-predefined-ent hence NCR should only be used if authoring XHTML and not using one of those 5 and HTML 4.01 only has 4 of those.

Numeric character references, both decimal and hexadecimal, can be safely used in (X)HTML and XML, but you need to be careful that you’re referencing the character’s code point from the Unicode character repertoire, not Windows-1252.