2

i want show 12"3 in my input tag value

i write this:

<INPUT TYPE="text" NAME="" value="12\"3">

but it's not be right

WHY ?

PS: i must transfer " to &quot; ,or change " to '? i don't like it

Koerr
  • 15,215
  • 28
  • 78
  • 108

2 Answers2

8

HTML simply does not have escape sequences like other languages. In HTML attribute values the only special characters are <, & and depending on the quotes " or '. And the only to use these characters are character references:

Some authors use the character entity reference "&quot;" to encode instances of the double quote mark (") since that character may be used to delimit attribute values.

Or you use single quotes, then you don’t need to encode the double quotes and vice versa:

<INPUT TYPE="text" NAME="" value='12"3'>
Gumbo
  • 643,351
  • 109
  • 780
  • 844
  • but this solution can't type `'` in tag value – Koerr Sep 03 '10 at 08:28
  • @Zenofo: If you want to use both single and double quotes in the same attribute value, then you need to represent one of these characters with a character reference: `"'""` or `'"''`. – Gumbo Sep 03 '10 at 08:31
  • @Zenofo Of course it can, you just need to use the HTML entity `'` or `'`. – slikts Sep 03 '10 at 08:32
  • 4
    @Reinis I.: `'` is not defined in HTML; it was introduced in XML 1.0. – Gumbo Sep 03 '10 at 08:35
  • The only XHTML correct way is to use the entities, `"` and `'` – ocodo Sep 03 '10 at 09:04
  • @Gumbo that's correct they equate to the same thing. I intended my comment to read... "The only XHTML correct way is to use the entities" ... and provided the symbolic entities for reference. – ocodo Sep 03 '10 at 09:43
  • @slomojo: But `'` and `'` are not entities; they are character references. *apos* and *quot* are entities that can be referenced with the corresponding entity references `'` and `"`. – Gumbo Sep 03 '10 at 09:54
  • @Gumbo, I know, I was just being simplistic. – ocodo Sep 03 '10 at 12:10
5

WHY ?

Because \ is not special in HTML. It does not escape stuff. You must use &quot; or '.

 <input type="text" name="somename" value='12"3' />
 <input type="text" name="somename2" value="12&quot;3" />
kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005