用于其id在“foo:bar”中的元素的CSS选择器形成 [英] The CSS selector for an element that its id is in the "foo:bar" form

查看:139
本文介绍了用于其id在“foo:bar”中的元素的CSS选择器形成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用JSF Web应用程序框架时,表单中的元素的ID可以由框架自动生成,并且当组件驻留在其ID为 form1 ,框架会自动以 form1:foo 的形式为该元素生成一个ID。虽然这可以关闭,我想知道是否可以为元素定义一个CSS ID选择器,其ID是 foo:bar 的形式。



提前感谢。

解决方案

根据 W3c spec 链接到这个回答,如果使用非转义,在元素ID中使用冒号是不对的。



< blockquote>

在CSS中,标识符(包括选择器中的元素名称,类和ID)只能包含字符[a-z0-9]和ISO 10646字符U + 00A1及以上, ( - )和下划线(_);它们不能以数字开头,或者连字符后跟数字。标识符还可以包含转义字符和任何ISO 10646字符作为数字代码(见下一项)。例如,标识符B& W可以写为B \& W \?或B \26 W \3F。


JSF框架是否真的在最终呈现的HTML中输出这些ID? / p>

When using the JSF Web application framework, ID of the elements inside a form can be automatically generated by the framework and when a component resides in a form that its ID is form1, the framework automatically generates an ID in the form of form1:foo for that element. While this can be turned off, I was wondering if it's possible to define a CSS ID selector for elements that their ID is in the form of foo:bar.

Thanks in advance.

解决方案

According to the W3c spec linked to in this answer, using colons in element IDs is plain wrong if used unescaped.

In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-z0-9] and ISO 10646 characters U+00A1 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, or a hyphen followed by a digit. Identifiers can also contain escaped characters and any ISO 10646 character as a numeric code (see next item). For instance, the identifier "B&W?" may be written as "B\&W\?" or "B\26 W\3F".

Is the JSF framework really outputting those IDs in the final rendered HTML?

这篇关于用于其id在“foo:bar”中的元素的CSS选择器形成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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