HTML id 属性中的冒号是什么意思?

2022-01-18 00:00:00 tags html css colon

我已经看到了这样一个用于 ID 属性的 HTML 代码:

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 (:)?

谢谢.

推荐答案

ID 属性中允许使用冒号,但没有特殊意义.不建议使用它们,因为它们有时会导致问题,例如与 jQuery 或 CSS 一起使用时,冒号作为伪选择器具有特殊含义.

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.

相关文章