Reputation: 346
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")
This JavaScript creates a <a>
element with the name "HTML_String."
How do I access only this element in my CSS?
Upvotes: 7
Views: 10406
Reputation: 29
[name="yourName"]
or if it only should have any name:
[name]
an example for an input:
input.myClass[name="greatName"] {
...
}
But if your question is how to look for something within your "innerHTML": This isn't possible.
Upvotes: 3
Reputation: 1817
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.........).
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.
Add a class to the element and then a.myclass
Upvotes: 4
Reputation: 944431
CSS doesn't have a specific selector syntax for name attributes. You have to use the generic attribute selector syntax.
[att=val]
Represents an element with the att attribute whose value is exactly "val".
Upvotes: 7
Reputation: 6878
use the [attribute=value] css selector, you can access it by using :
a[name=HTML_STRING] {
//your css
}
Upvotes: 3