Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

  1.  permalink
    There are a couple of things that I simply do not get with CSS.

    Why would you do the following:

    #div-id-name, #div-id-name2 div.classname {something:something;}

    My thinking is that you are declaring the value for the div only with the class “classname” in the divs “div-id-name” and “div-id-name2”. That seems SO complicated.

    Why wouldn’t you just declare the class value? Why get specific with the class and specify the class “classname” as the child of a div?

    Any help would be great.
    •  
      CommentAuthorSpookyET
    • CommentTimeJan 25th 2006 edited
     permalink
    .className - <-- all elements with classname will be styled.
    div .className <-- all elements inside that div that have className will be styled
    div.className <-- only divs with class className will be styled.
    • CommentAuthorspyyddir
    • CommentTimeJan 25th 2006
     permalink
    Spooky, "." means that its a class, not an id.

    div.className <-- only divs with class className will be styled.
  2.  permalink
    For one, selectors.

    Second, I prefer them for two reasons:

    1. Debugging - I can tell if #someID has to be a division or if it can be a paragraph based on the properties and values declared. I don't want to search through my HTML document to find if #someID is a division or what. Also, if you're letting someone else skin your site (or create their own styles for forums and such) it's easier for them.
    2. Selectors.
    •  
      CommentAuthordave.merwin
    • CommentTimeJan 25th 2006 edited
     permalink
    nick1presta, I almost get what you are saying.

    1. What is a division?
    2. What do you mean about Selectors? I know what they are, but I am missing something.

    Thanks.
    •  
      CommentAuthorSpookyET
    • CommentTimeJan 25th 2006
     permalink
    spyddir, whre did you get the idea that i don't know the different between a class and an ID?
    • CommentAuthorspyyddir
    • CommentTimeJan 25th 2006 edited
     permalink
    Here:

    div.className <-- only divs with id class name will be styled.
    •  
      CommentAuthorSpookyET
    • CommentTimeJan 26th 2006
     permalink
    typo, fixed
  3.  permalink
    @dave.merwin:

    A division is the proper name for a 'div' tag (<div>).

    And selectors are ways to select specific objects within a document without resorting to classes or IDs.

    Such as,

    p { color: red; }
    div > p { color: blue; }

    Paragraphs within a division will be blue whereas they will be red elsewhere. You don't need to add a class or ID to the paragraph you want blue.
Add your comments
    Username Password
  • Format comments as (Help)