jQuery in Action, 2nd edition*
The moose likes HTML, CSS and JavaScript and the fly likes Applying styles in CSS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Applying styles in CSS" Watch "Applying styles in CSS" New topic
Author

Applying styles in CSS

Rajesh Khan
Ranch Hand

Joined: Oct 16, 2011
Posts: 230
Hi i was hoping to get a little help on this issue
I actually wanted to know what the difference is between these two


Here is my understanding of .upload label which i am sure is correct
this means apply the style to all the label tags in the upload class

Now i am a bit confused with the label.upload but i think it means
apply this style to all the label tags in the upload class. (is this correct??) if so then why doesnt the style take effect if i replace .upload label with label.upload in the following example


<style type="text/css">
.upload {width:80em;background-color:red}
.upload label {width: 8.5em;float: left;text-align: left;margin-right: 0.9em;margin-left: 1em ; position:relative ; top:4px;background-color:blue}
</style>

<div class="upload">
<label>labelA</label <br>
<label>labelB</label><br>
</div>
Marcin Kwiatkowski
Ranch Hand

Joined: Aug 06, 2007
Posts: 32

label.upload matches label element with upload class: <label class="upload">
Rajesh Khan
Ranch Hand

Joined: Oct 16, 2011
Posts: 230
Marcin Kwiatkowski wrote:label.upload matches label element with upload class: <label class="upload">

What does that mean ?? sorry i am a bit confused with your explaination . does this mean
"apply the given style to all label tags in the upload " ??
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Read this: http://htmlhelp.com/reference/css/structure.html

Eric
Marcin Kwiatkowski
Ranch Hand

Joined: Aug 06, 2007
Posts: 32

No, it means "apply the given style to all label tags with upload class", so that it would be applied to <label class="upload">...</label>, but not to <label>...</label>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

Rajesh Khan wrote:Here is my understanding of .upload label which i am sure is correct
this means apply the style to all the label tags in the upload class

Apply the rule to all label elements that are descendants of an element with the class upload.

Now i am a bit confused with the label.upload but i think it means
apply this style to all the label tags in the upload class. (is this correct??)

Apply the rule to all label elements with the class upload.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
GeeCON Prague 2014
 
subject: Applying styles in CSS