I have a label in my web page as label for="title" How can i style this specific label element?
-
possible duplicate of [Is it possible to format an HTML tooltip?](http://stackoverflow.com/questions/484137/is-it-possible-to-format-an-html-tooltip) – Pekka Oct 27 '10 at 10:26
-
Oh, my bad, I misunderstood the question. Sorry – Pekka Oct 27 '10 at 10:30
-
1How annoying that IE6 doesn't support basic CSS selectors. To be honest, I've given up trying to support IE6 now; it's just not worth the effort, and its market share is falling all the time. But if you do still have to support it, I feel for you. – Spudley Oct 27 '10 at 11:24
4 Answers
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.

- 1
- 1

- 21,501
- 8
- 58
- 94
you can assign it an id
<label for="title" id="label-title">TITLE</label>
then apply some css, eg
#label-title{font-weight:bold}

- 1,116
- 8
- 16
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!!

- 166
- 2
- 5
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}

- 3,474
- 3
- 24
- 42