Black
Black

Reputation: 20212

How do I select an element with [] in its name attribute?

I try to create a new style for phpmyadmin with the browser extension stylus.

How can I select this select by name:

<select name="criteriaTables[]" multiple="">

I tried it like this:

form#db_search_form select[name=criteriaTables] {
    min-height: 400px;
}

...but it does not work.

form#db_search_form select[name=criteriaTables[]] {
    min-height: 400px;
}

...does not work either.

Upvotes: 0

Views: 62

Answers (2)

Tec J
Tec J

Reputation: 118

Try below.

<style type="text/css">

select[name^="criteriaTables"] {
    min-height: 400px;
}

</style>

Upvotes: -2

BenM
BenM

Reputation: 53198

Wrap the attribute value in quote marks ("):

select {
  width: 200px;
}

select[name="criteriaTables[]"] {
    min-height: 400px;
}
<select name="criteriaTables[]" multiple="">
  <option>1</option>
  <option>2</option>
  <option>3</option>
</select>

Alternatively, you can also escape the square brackets:

select {
  width: 200px;
}

select[name=criteriaTables\[\]] {
    min-height: 400px;
}
<select name="criteriaTables[]" multiple="">
  <option>1</option>
  <option>2</option>
  <option>3</option>
</select>

Upvotes: 7

Related Questions