30

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?

JD Isaacks
  • 56,088
  • 93
  • 276
  • 422
  • What about selecting whether an attribute is present with any value? Would something like `input[type=number][step]` select all number inputs with the step attribute? – Matt W Dec 09 '16 at 11:36

3 Answers3

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

MvanGeest
  • 9,536
  • 4
  • 41
  • 41
5

You can use multiple attributes as follows:

input[type=submit][value=Delete] {
    /* some rules */
}
Pat
  • 25,237
  • 6
  • 71
  • 68
2

You can just chain the attribute selectors

input[type="submit"][value="delete"]
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
CEich
  • 31,956
  • 1
  • 16
  • 15