George McKenzie
George McKenzie

Reputation: 115

How to hide a label element with no class?

Trying to hide an element in the WooCommerce plugin for Wordpress. Basically it's on the check out page and it says "State" and I want to hide it because the drop down box already says "Select State." I open Firebug and saw that the text "State" is not part of a class or anything. It looks like this:

<label class="" for="billing_state">
State
<abbr class="required" title="required">*</abbr>
</label>

I tried adding this in my CSS but it didn't work

label [for="billing_state"]{
display: none;
}

Upvotes: 1

Views: 263

Answers (3)

Paul S.
Paul S.

Reputation: 66324

You can select a node with an empty class attribute <span class="" /> using

span[class=""] {
    border: 3px solid red;
}

You can select a node with explicitly no class attribute <span /> using

span:not([class]) {
    border: 3px solid blue;
}

Demo

Upvotes: 0

DaniP
DaniP

Reputation: 38252

Your CSS works just remove the space between label and the [selector]:

label[for="billing_state"]{
  display: none;
}

The demo http://jsfiddle.net/6hKPL/

Upvotes: 2

Matt
Matt

Reputation: 75317

There shouldn't be a space between the label and the [; otherwise you're searching for elements which are descendants of a label, which match [for="billing_state"].

label[for="billing_state"]{
    display: none;
}

http://jsfiddle.net/J3BgS/

Upvotes: 1

Related Questions