为什么不能使用\“在HTML输入标签?

编程入门 行业动态 更新时间:2024-10-23 18:35:50
本文介绍了为什么不能使用\“在HTML输入标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在我的输入标签值中显示 123

我写这个:

< INPUT TYPE =textNAME =value =12 \3>

但它不正确

WHY ?

PS:我必须将转移至& quot; ,或将更改为'?我不喜欢它

解决方案

HTML没有像其他语言一样的转义序列。在HTML属性值中,唯一的特殊字符是< ,& ,并且取决于引号或',并且唯一使用这些字符的是字符引用:

有些作者使用字符实体引用& quot; 来编码双引号标记()的实例,因为该字符可能用于分隔属性值。

或者您使用单引号,则不需要对双引号进行编码,反之亦然:

< INPUT TYPE =textNAME =value = '123'>

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

解决方案

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

更多推荐

为什么不能使用\“在HTML输入标签?

本文发布于:2023-10-31 04:58:37,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标签   HTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!