Stoob Stoob - 2 years ago 74
CSS Question

How to hide element label by element id in CSS?

Let's say I've got this code

<td><input id="foo" type="text"></td>
<td><label for="foo">This is foo</label></td>

This will hide the input:

#foo { display: none;} /* or hidden could work too, i guesss */

How do I hide the label?

Answer Source

If you give the label an ID, like this:

<label for="foo" id="foo_label">

Then this would work:

#foo_label { display: none;}

Your other options aren't really cross-browser friendly, unless javascript is an option. The CSS3 selector, not as widely supported looks like this:

[for="foo"] { display: none;}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download