CSS选择器的< a>名称属性? [英] CSS Selector for name attribute of <a>?

查看:102
本文介绍了CSS选择器的< 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 classes for CSS (even for unique elements) and ids for JavaScript, while you'll leave the names for backend programming.

向该元素添加一个类,然后a.myclass

Add a class to the element and then a.myclass

这篇关于CSS选择器的&lt; a&gt;名称属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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