views:

50

answers:

4

I have a label in my web page as label for="title" How can i style this specific label element?

+2  A: 

Since IE6 doesn't support attribute selectors, you might consider specifying a class attribute to your <label /> and select it with it. (See How to workaround: IE6 does not support CSS “attribute” selectors)

With IE7, you could just do this:

label[for="title"] {
   font-weight: bold;
   /* ... */
}

See jsfiddle.net/GWNXq.

Bertrand Marron
In IE 6 / 7? ` `
Pekka
Oh, nevermind, wasn't paying attention. :)
Bertrand Marron
+6  A: 

you can assign it an id

<label for="title" id="label-title">TITLE</label>

then apply some css, eg

#label-title{font-weight:bold}
Rocket Ronnie
Pretty much one of the only (easy) ways to accommodate IE6. +1
BoltClock
+2  A: 

Like Rocket Ronnie states, id is one way of doing it.

You can even supply a class, that way you can style several things at once

<label for="title" class="label">TITLE</label>
<label for="title" class="label">FORENAME</label>

then apply some css, eg

.label{font-weight:bold}
jimplode
+1  A: 

Hi all,

Thanks for ur answers!

This is what i found after hours of "googling"

I think in IE6 we must use id or class attributes otherwise its not possible to select the label element as said above in most of the anwers!

label[htmlFor="title"]{... } for IE7

label[for="title"]{... }for FF 3.5(I have not tested it on safari)

reference - http://reference.sitepoint.com/css/attributeselector

P.S: Its still not working in IE7!!

srinath