开发者

What are the rules for HTML attribute values?

When declaring an a开发者_如何学运维ttribute value such as id="attributeValue" are there any particular rules on what characters are/aren't allowed?

I have always assumed that the first letter must always be a letter (a-z or A-Z) followed by pretty much any character(s). Then I realised this is the rules for declaring PHP variables

So what are the rules for declaring an attribute, and are they the same for all attributes e.g. id, name, href, type etc


ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

http://www.w3.org/TR/html401/types.html#h-6.2

So, your assumptions is pretty good, but "followed by pretty much any characters" is a bit optimistic.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜