Got more questions? Find advice on: SQL | XML | Regular Expressions | Windows
in Search
Welcome to AspAdvice Sign in | Join | Help

CSS quick Q: What's difference between div.commentdiv and #commentdiv?

Last post 12-14-2007, 2:58 AM by DougJoseph. 9 replies.
Sort Posts: Previous Next
  •  12-07-2007, 3:07 PM 37373

    CSS quick Q: What's difference between div.commentdiv and #commentdiv?

    Hey Carl

    I'm a newbie at CSS. Quick Q:

    What's the difference between placing :

    div.commentdiv {

    }

    ... and placing :

    #commentdiv {

    }

    Can the latter affect divs plus other stuff, while the former only affects divs? Or can the latter not affect divs but can affect something else? (And if so, what?)

    Sorry I know so little on this.


    Sincerely,
    Doug Joseph
    Filed under: ,
  •  12-07-2007, 4:02 PM 37377 in reply to 37373

    Re: CSS Primer

    only one element on a page can have a specific id attribute 

    div#blah targets the div element with the id="blah" attribute

    #blah targets the one element with the id="blah" attribute

    any number of elements on a page can specify the same class attribute 

    div.flibberty targets the div element(s) that contain the class="flibberty" attribute

    .flibberty targes any element(s) that contain the class="flibberty" attribute

     
    Read more about CSS and specificity:  CSS Specificity for Poker Players

     
    PS: I don't play cards (anymore)


    Sincerely,

    Carl
    -----
    vine type - content management with standards in mind - vinetype.com
    -----
    Filed under: , ,
  •  12-07-2007, 9:51 PM 37392 in reply to 37377

    Re: CSS Primer

    Excellent! Thanks!

    I'm digging into CSS.

    Why? I'm considering the possibility of moving the left nav to the top -- making it horizontal instead of vertical. (This would be like how you have it on the VineType site, or something similar.) The reason I'm thinking about it is that I find myself wishing the page was wider.

    "Real estate" on the page is limited, width-wise, if we want to stay viewable on a screen res of 800 x 600. Google's ad-enabled search results in the middle "content" column beg that column's width to be at least 500px, minimum. Google's (and just about anyone else's, I guess) verticle "side bar" ads are usually at least 120px wide. Having the navigation menu on the left seems to beg a minimum width of about 100px or more.

    Regarding the possibility of moving the nav menu to the top, I'm certainly open to advice and counsel. I know that a blog's nav tree usually needs that unlimited vertical room to grow. But I'm even thinking of drop downs... I would be deeply indebted if you have any tips or pointers or advice or counsel on that potential switchover....  :-)

    I really like the VineType software and its whole approach.

    If making the switch to top-mounted nav proves too big a mouthful to chew or just wrong (bad idea), I may give up on the 800x600 screen res, and do like Andreas Viklund does (use a wider page width, targeting a minimum screen res of 1024).


    Sincerely,
    Doug Joseph
    Filed under: , ,
  •  12-10-2007, 8:44 AM 37462 in reply to 37392

    Re: CSS Primer

    Did you try changing

    #wrap { width:760px }

    to something like these ??

    width: 980px;

    width: 90%;


    Sincerely,

    Carl
    -----
    vine type - content management with standards in mind - vinetype.com
    -----
    Filed under:
  •  12-10-2007, 8:43 PM 37512 in reply to 37462

    Re: CSS Primer

    The reason why I am not immediately going to that, is I have not yet decided to abandon the viewers who have 800x600 screen resolution. I know of a certainty several members of our church still use the lower resolution For now, staying down with them on the width, means more than trying to include that extra Google ad.
    Sincerely,
    Doug Joseph
    Filed under:
  •  12-10-2007, 9:06 PM 37514 in reply to 37512

    Re: CSS Primer

    The percentage works at the lower resolution and expands for higher resolution.  Give it a shot.

    width: 90%; 

     


    Sincerely,

    Carl
    -----
    vine type - content management with standards in mind - vinetype.com
    -----
    Filed under:
  •  12-10-2007, 10:12 PM 37522 in reply to 37514

    Re: CSS Primer

    But at the lower resolution, its width would shrink down too narrow to hold all three columns, if the right column has a verticle Google ad in it (minimum 120px wide), and the middle column is set to 500px wide so it can accommodate Google-ad-enabled web search results (like my site is set for now; note: that's a web search, in addition to the VineType site search results; I'm offering the user the ability to search either way, either web or site), and the left column is necessarily wide enough to show the words of the nav structure. There is simply not enough width to add the verticle Google ad on the right side, and still accommodate 800 screen res, and keep the nav on the left, and keep the 500px web search results in the middle. Something would have to be shoved off the screen, even using a %. For now, I'm letting go of the verticle Google and hanging on to my readership using 800 screen res. It's not like I don't have Google ads running. I have a huge Google leaderboard running at the top, above my header. So I'm fine with letting go of the vertical ad on the right.
    Sincerely,
    Doug Joseph
  •  12-12-2007, 12:14 AM 37576 in reply to 37522

    Re: CSS Primer

    what if you set the wrapper to 90% and the google ad div to 500px?  Sure the ad won't stretch, but the articles would.  and the ad width would sort of act like a min-width I would think.

    Sincerely,

    Carl
    -----
    vine type - content management with standards in mind - vinetype.com
    -----
    Filed under: ,
  •  12-12-2007, 9:17 AM 37585 in reply to 37576

    Re: CSS Primer

    FWIW all your 800x600 visitors (based on my experience) maximize every window on their screen.

    Sincerely,

    Carl
    -----
    vine type - content management with standards in mind - vinetype.com
    -----
  •  12-14-2007, 2:58 AM 37663 in reply to 37576

    Re: CSS Primer

    carlcamera:
    what if you set the wrapper to 90% and the google ad div to 500px?  Sure the ad won't stretch, but the articles would.  and the ad width would sort of act like a min-width I would think.
    Thanks for all your help! I'm very pleased with my present set up. Big leaderboard ad across the top, and the 500px search results with ads, in the middle -- it's doing well. Check it out at www.dougjoseph.net
    Sincerely,
    Doug Joseph
    Filed under: ,
View as RSS news feed in XML