Stoob Stoob - 8 months ago 22
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?


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;}