HTML文件中的元素ID〜命名问题 [英] Element ID in HTML Document ~ Naming Question
问题描述
在元素ID中放置空格字符是否存在任何问题(技术上或其他方式)?例如,这样的东西:
Are there any issues (either technically, or otherwise) with putting a space character in an element ID? For example, something like this:
<li id='something with spaces'>Test123</li>
我明白这不是可取的(我从未在空格之前使用过 ),但是如果可能,我已经打了一个scneario,我需要这样做。
I understand that this is NOT desirable (I have never used spaces before), but I have hit a scneario where I need to do this if possible.
有什么潜在的问题(如果有的话)面对缩放,任何特定的浏览器,脚本或CSS样式?
What are the potential issues (if any) I may face with scaling, any particular browsers, scripting, or CSS styling?
有没有关于可以使用但不能使用的坏字符的文章?
Are there any articles that talk about the 'bad characters' that CAN be used but SHOULD NOT be used?
谢谢 -
推荐答案
Per 标准,
ID和NAME标记必须以
字母([A-Za-z])开头,并且可以通过任意数字的字母
跟随
,数字
([0 -9]),连字符( - ),下划线
(_),冒号(:)和句点
(。)。
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 (".").
通过打破这个规则,你可能没有遇到麻烦,您的(无效)HTML的标准处理器。所以,我建议你不要这样做。
By breaking this rule you'r likely to run into no end of trouble from standard-complying processors of your (invalid) HTML. So, I would recommend you don't do this.
这篇关于HTML文件中的元素ID〜命名问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!