Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Selector for name attribute of <a>?

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?

like image 375
Owen L. Avatar asked May 15 '16 18:05

Owen L.


People also ask

How do you target a name attribute in CSS?

The [attribute|="value"] selector is used to select elements with the specified attribute, whose value can be exactly the specified value, or the specified value followed by a hyphen (-). Note: The value has to be a whole word, either alone, like class="top", or followed by a hyphen( - ), like class="top-text".

What is the CSS selector for an a tag containing the title attribute?

The [attribute~=value] selector is used to select elements with an attribute value containing a specified word.

How do I select an element by attribute name?

To select elements by an attribute name, pass a selector with the attribute's name to the querySelectorAll() method, e.g. document. querySelectorAll('[title]') . The querySelectorAll method will return a collection of the elements that have the provided attribute set.

How do I select a tag name in CSS?

The CSS id Selector The id selector uses the id attribute of an HTML element to select a specific element. The id of an element is unique within a page, so the id selector is used to select one unique element! To select an element with a specific id, write a hash (#) character, followed by the id of the element.


1 Answers

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".

like image 187
Quentin Avatar answered Sep 21 '22 16:09

Quentin