Dorothy Hesson 2336 wrote:
> Hello -
>
> I am quite baffled here. I know I am totally missing something, but I
> simply can't see it! Can you assist, please?
>
> I am trying to float an image right within a #content div. When I place
> the following rule in the <head> element within <style> tags, the image
> floats correctly.
>
> .floatright {
> float: right;
> margin: 0 0 10px 10px;
> border: 1px solid #666;
> }
>
> Now, when I take the same class rule and place it within the main.css
> stylesheet, the image does not see the rule. 
>
> I know this is an example of something I don't quite have fully understood.
>
> If you have any suggestion, I'd appreciate it. Please copy me on a reply
> as I am on the digest, and would love to proceed with this project soonest!
>
>   
The way that CSS applies styles is interesting, but it makes sense. If 
specificity is equal between two declarations, it applies the style 
declaration "closest" to the HTML tag it is modifying. So an inline 
style would be applied first, followed by any <style> declarations in 
the page <head>, followed by external declarations in reverse order of 
appearance in the file.

That is why your rule worked in the page <head>, but not in the .css 
file. You would have to give the rule a higher specificity score in the 
.css file by adding an id or element tag name in front of it.

For example, #id .class will take precedence over .class, and element 
.class would take precedence over both of those.

- JCD
______________________________________________________________________
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to