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
  • 53,624
  • 90
  • 270
  • 419
  • 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? – TransitoryMatt Dec 09 '16 at 11:36

3 Answers3

68
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,406
  • 4
  • 40
  • 41
5

You can use multiple attributes as follows:

input[type=submit][value=Delete] {
    /* some rules */
}
Pat
  • 24,658
  • 6
  • 71
  • 67
2

You can just chain the attribute selectors

input[type="submit"][value="delete"]
BoltClock
  • 665,005
  • 155
  • 1,345
  • 1,328
CEich
  • 29,554
  • 1
  • 14
  • 15