开发者

why can't use \" in HTML input tag?

i want show 12"3 in my input tag value

i write this:

<INPUT TYPE="text" NAME="" value="12\"3">开发者_JAVA百科;

but it's not be right

WHY ?

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


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'>


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" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜