PDA

View Full Version : how to ignore css



esthera
Nov 19th, 2006, 08:01 AM
if i have let's say a css that applies a css to all the

labels within div1 --
now what if i have 1 label that I don't wnat that css to apply to -- how can I set it not to apply to that?

Arbitrator
Nov 19th, 2006, 08:27 AM
There are multiple methods of doing that. You can assign an ID to the odd label or mark up all of the labels with classes to differentiate them; in this case, you would only have two classes, so an ID would be more efficient. If the label has a unique attribute, you can use an attribute selector to apply styles to it. You can also use the sibling selector, though doing so would produce a long string of code and some redundancy unless the label was the last in the div element. As a last resort, you could target it based on its position in the document using JavaScript. The method you would use depends on whether you can edit the HTML and whether or not you need to support Internet Explorer 6 with its significant limitations.

esthera
Nov 19th, 2006, 08:31 AM
so then let's say my default is to float the text with a width of 25% --
and I put an id to the tag that I dod not want floated or the width set --
what would I put for the css for that id tag?

Arbitrator
Nov 19th, 2006, 09:15 AM
You would use float: none and width: auto.