Nishant
Nishant

Reputation: 21914

Why does & become &

We have a TinyMCE Editor and we sent the images that can be inserted into the editor like this:

'test?foo=something&bar=something'

When I view the source in TinyMCE it becomes :

<img src="test?foo=something&amp;bar=something"/>

Why does & become &amp;? What is the main idea behind that?

Which software does this conversion automatically because I can't see any explicit code . I am aware of HTML Entities .

Upvotes: 4

Views: 8847

Answers (3)

user1419238
user1419238

Reputation: 46

There are some special characters which are reserved in HTML. These characters can not be used directly like other character.

For example, all the tags in HTML are enclosed in LESS THAN and GREATER THAN signs (ie '<' and '>'). So to display the '>' or '<' sign in HTML page, it converts the character to HTML code. These HTML codes are converted to ascii character by the browser.

& is the HTML code for '&'.

There are many other special characters. Some of them are listed in the link below.

http://www.w3schools.com/html/html_entities.asp

Upvotes: 2

Bonomi
Bonomi

Reputation: 2753

Certain characters cannot be used within XML because they have special meanings. These characters have to be escaped with the following predefined entities. If you use one of the characters listed below, substitute it with the appropriate string:

ampersand (&) is escaped to &amp; 
double quotes (") are escaped to &quot; 
single quotes (') are escaped to &apos; 
less than (<) is escaped to &lt; 
greater than (>) is escaped to &gt;

Upvotes: 0

Djoezz
Djoezz

Reputation: 80

Html doesnt accept tokens like &. And have special html codes for them:

http://www.ascii.cl/htmlcodes.htm

more about entities:

http://www.w3schools.com/html/html_entities.asp

Try not to save your files with such tokens in them since it can make things complicated.

Upvotes: 0

Related Questions