<div style="position: absolute; left: 0px; top: 5px;" class="v-caption v-caption-top_header">
<div class="v-captiontext">Create User Wizard</div><div style="clear: both; width: 0px; height: 0px; overflow: hidden;">
</div>
</div>
<div style="top: 70px; left: 10px;" class="v-absolutelayout-wrapper">
<div style="height: 5px; width: 1257px;" class="v-label v-label-intro_key intro_key">
</div>
</div>
<div style="position: absolute; left: 10px; top: 55px;" class="v-caption v-caption-intro_key">
<div class="v-captiontext">User Details.
</div>
I have to apply some styles to Create User Wizard text. But I cannot refer v-captiontext css class directly becoz the same css class is used by other text also for example User Detailstext. How can apply changes to only Create User Wizard text.
You can refer to nested classes. In your current HTML you could refer to
v-caption-top_headerwithv-captiontextinside it like this:or
(the first of these specifies that
v-captiontextis somewhere beneathv-caption-top_headerin the DOM, whereas the second one specifies that it is a direct child; ie immediately beneath it in the DOM. The second one is probably preferable, except that it doesn’t work in IE6, so if you need to support IE6 then use the first one)The other options you have would require you to change the HTML code.
You could give the
Create User Wizardelement a specific ID and use that instead of the class:or use multiple classes:
In this case, the choice between ID or class would depend on whether you is bit of styling on this element is going to be unique – if it is specific to this element then use an ID; if you want to use it elsewhere then use a class.
If you still have problems, you could try using some trickier solutions:
CSS supports attribute selectors, which allow you to select elements based on specific HTML attributes. This can be very useful, but I don’t think it’ll help you here (since you don’t have much in the way of attributes other than styles and classes anyway). Also this again doesn’t work in IE6.
Another option could be pseudo-selectors such as
:first-childor:nth-child(). Using these you could for example specify that the first matching element gets one style and others get something else. These may actually be useful for you, in conjunction with other techniques above. However you’ll have problems with these with all current versions of IE, so probably not recommended.There’s a very good overview of the available CSS selectors, along with which browsers support them at Quirksmode.org: http://www.quirksmode.org/css/contents.html