使用"_"有什么问题吗?(下划线)在html属性中? [英] Is there anything wrong with using "_" (underscore) in an html attribute?

查看:55
本文介绍了使用"_"有什么问题吗?(下划线)在html属性中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用下划线"_"作为框架的键名.将标签的属性名称设置为下划线有什么问题吗?例如

I want to use the underscore "_" symbol as a key name to my framework. Is there anything wrong with setting the name of anattribute of a tag to an underscore? for example

<div class="dropdown sandstone-texture" _="choices"></div>

为此.那"$"呢?

推荐答案

简而言之, _ 作为整个属性的名称被认为是错误的,因为它是唯一的字符,因此也是第一个字符,并且只要您将其称为"HTML"属性,就确实存在针对以 _ 开头的属性名称的HTML规则.

In short, _ as the entire attribute's name, is considered wrong because since it is the only character it is also the first character, and as long as you are calling this an "HTML" attribute, there is indeed an HTML rule against attribute names starting with _.

来自 20 SGML HTML 4声明:

NAMING   LCNMSTRT ""
         UCNMSTRT ""
         LCNMCHAR ".-_:"    
         UCNMCHAR ".-_:"
         NAMECASE GENERAL YES
                  ENTITY  NO

SGML和HTML解释了:

默认情况下,SGML假定名称只能以字母字符开头,无论是哪种移位,其后的字符都是字母数字.语法子句中的LCNMSTRT和UCNMSTRT条目允许将其他非字母数字字符定义为名称起始字符,LCNMCHAR和UCNMCHAR条目定义哪些非字母数字字符可以用作名称起始字符之后的名称字符.

因此,我们看到 _ LCNMCHAR UCNMCHAR 中列出,并且在名称开头后应为/code>,而不是之前.

So it we see _ is listed in LCNMCHAR, UCNMCHAR, and that they are to be after a name start, not before.

在SGML中禁止使用ASCII字符属性?

这篇关于使用"_"有什么问题吗?(下划线)在html属性中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆