What does a colon mean within an HTML id attribute?

妖精的绣舞 提交于 2019-12-05 11:51:09

问题


I have seen an HTML code like this for the ID attribute:

id="t1:c3"

Can someone explain this to me? What is the purpose of the colon (:)?

Thank you.


回答1:


Colons are allowed inside ID attributes, but hold no special significance. It's not really advisable to use them because they can sometimes cause problems, such as when used with jQuery or CSS, where the colon has special meaning as a pseudo-selector.




回答2:


If the HTML is generated with Java ServerFaces this usually produces such IDs, i.e. if the form has the ID form1 and the element has the ID firstName this results in an ID form1:firstName if the element is on top level, if there are several ones created in a loop they look like form1:1:firstName, form1:2:firstName, …

This framework behaviour cannot be changed.




回答3:


In addition to the above I have discovered that Omniture uses colons to help define classes related to the layout.



来源:https://stackoverflow.com/questions/3544898/what-does-a-colon-mean-within-an-html-id-attribute

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!