Click to See Complete Forum and Search --> : style in JSP


manishrathi
09-23-2009, 02:23 PM
I have a style applied in JSP as below
<style>
.bb_hpList .promotionsTV[class] {
min-height:200px;
}
.bb_hpList .promotionsTV {
height:240px !important;
}
</style>

when it say .bb_hpList .promotionsTV , it means two classes bb_hpList and promotionsTV are applied to this element. what does the syntax ".bb_hpList .promotionsTV[class]" mean ?

thanks

nathandelane
09-30-2009, 12:06 AM
The syntax ".bb_hpList .promotionsTV[class]" means


An element that is contained by an element with class "bb_hpList" and itself has the class "promotionsTV".


An example might be:

<div class="bb_hpList">
<div class="promotionsTV">
</div>
</div>


I think that [class] is redundant in this situation and so I'm not certain why its there. Another pattern that you might see is

.bb_hpList.promotionsTV {
...
}


And this refers to the pattern

<div class="bb_hpList promotionsTV"></div>

slaughters
09-30-2009, 05:32 PM
When you see the square brackets attached to a class or tag name in CSS it is called an attribute selector. It will only apply the style if the element also has the attribute contained in the square brackets.

Example:

a[title] {
color : blue ;
}
.
.
<a href="blah.html">Blah</a> - will NOT be blue
<a href="blah.html" title="something">Blah 2</a> - will be Blue

Since the second link has the attribute "title" in its anchor tag the style is applied to it. Attribute Selectors are not terribly well supported yet, so you don't see them very often. You can find more about selectors here:
http://www.webteacher.ws/2008/02/15/attribute-selectors-in-css/

How it is being used in the manishrathi example does not make sense to me at all. Anything with a class name will have the class attribute.

nathandelane
09-30-2009, 09:15 PM
Haha, that's what I said -- .className[class] is redundant.