CSS选择器的< a>名称属性? [英] CSS Selector for name attribute of <a>?
问题描述
这可能是一个愚蠢的问题,但是<a>
属性的名称"的CSS选择器是什么?
This may be a dumb question, but what is the CSS Selector for the attribute of <a>
that is "name"?
document.body.innerHTML = myString.anchor("HTML_String")
此JavaScript创建名为"HTML_String."
的<a>
元素
如何仅在CSS中访问此元素?
This JavaScript creates a <a>
element with the name "HTML_String."
How do I access only this element in my CSS?
推荐答案
有[name="name"]
选择器,但它并不是真正的跨浏览器.旧版本的Internet Explorer不支持HTML属性选择器(该浏览器可以通过.........).
There is the [name="name"]
selector but it's not really cross-browser. Old versions of Internet Explorer don't support the selector by HTML attribute (that browser tho.........).
我的建议是始终将class
用于CSS(甚至用于唯一元素),将id
用于JavaScript,而将name
留给后端编程.
My suggestion is to always use class
es for CSS (even for unique elements) and id
s for JavaScript, while you'll leave the name
s for backend programming.
向该元素添加一个类,然后a.myclass
Add a class to the element and then a.myclass
这篇关于CSS选择器的< a>名称属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!