JD Isaacks
JD Isaacks

Reputation: 57974

CSS how to target 2 attributes?

OK if I want to target an <input> tag with type="submit" I can do so like:

input[type=submit]

Also if I want to target an <input> tag with value="Delete" I can do so like:

input[value=Delete]

But How can I target an <input> tag with BOTH?

Upvotes: 30

Views: 18697

Answers (3)

CEich
CEich

Reputation: 33434

You can just chain the attribute selectors

input[type="submit"][value="delete"]

Upvotes: 2

Pat
Pat

Reputation: 25675

You can use multiple attributes as follows:

input[type=submit][value=Delete] {
    /* some rules */
}

Upvotes: 5

MvanGeest
MvanGeest

Reputation: 9661

input[type=submit][value=Delete]

You're chaining selectors. Each step narrows your search results:

input

finds all inputs.

input[type=submit]

narrows it to submits, while

input[type=submit][value=Delete]

narrows it to what you need.

Upvotes: 69

Related Questions