Web Hosting CSS & Stylesheet Forums

Add Me

User Name
Password
Go Back   CSS & Stylesheet Forums > CSS Forumz: Main > Style Sheet In General

Welcome to the CSS & Stylesheet Forums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Tags:



Reply
  #1 (permalink)  
Old 09-23-2008, 01:42 AM
shapper
Guest
 
Posts: n/a
Diggs:
Default Cascading Styles



Hello,

I have the following:

<div class="Body">
<div class="Content">
<h2>First Header</h2>
<div class="Post">
<h2>Second Header</h2>
</div>
</div>
</div>

I have:

div.Body div.Content h2 {font-size: 2em;--

div.Post h2 {font-size: 1em;--

The first header is with the right size but the second not ...
shouldn't this work?

What am I doing wrong? Should I make this differently?

Thanks,
Miguel

Reply With Quote


Sponsored Links
  #2 (permalink)  
Old 09-23-2008, 07:03 AM
Joshua Cranmer
Guest
 
Posts: n/a
Diggs:
Default Re: Cascading Styles

shapper wrote:
> Hello,
>
> I have the following:
>
> <div class="Body">
> <div class="Content">
> <h2>First Header</h2>
> <div class="Post">
> <h2>Second Header</h2>
> </div>
> </div>
> </div>
>
> I have:
>
> div.Body div.Content h2 {font-size: 2em;--
>
> div.Post h2 {font-size: 1em;--
>
> The first header is with the right size but the second not ...
> shouldn't this work?


I take it you want the first h2 to be 2em and the second to be 1em.

The answer is that the first one matches both: what it's saying is
"match all h2 elements that are descendents of div's of class Content
that are descendents of div's of class Body." The second one also
matches the latter one.

The spec says that the first one matches because it has more classes
than the second ones.

The cascade in short:
1. Prefer style="" on an element over anything else.
2. Else, prefer the one with more id references.
3. Else, prefer the one with more other attribute references.
4. Else, prefer the one with more elements.
5. Else, prefer the last one written.

--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
Reply With Quote


  #3 (permalink)  
Old 09-23-2008, 07:03 AM
dorayme
Guest
 
Posts: n/a
Diggs:
Default Re: Cascading Styles

In article
<54dec97f-4db4-4472-9f8b-6f1f2fe3bb85@x41g2000hsb.googlegroups.com>,
shapper <mdmoura@gmail.com> wrote:

> <div class="Body">
> <div class="Content">
> <h2>First Header</h2>
> <div class="Post">
> <h2>Second Header</h2>
> </div>
> </div>
> </div>
>
> I have:
>
> div.Body div.Content h2 {font-size: 2em;--
>
> div.Post h2 {font-size: 1em;--
>
> The first header is with the right size but the second not ...
> shouldn't this work?


Try

div.Content h2 {font-size: 2em;--
div.Content div.Post h2 {font-size: 1em;--

--
dorayme
Reply With Quote


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 10:24 PM.
Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.




Inactive Reminders By Mished.co.uk