#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    3
    Rep Power
    0

    Question Can somebody explaind me what these selectors do?


    Iím a newbie in CSS coding. Iíve got a web page to do a little redesign. But I donít know what all different selectors mean or do.
    So far I have managed to decode some CSS selectors (correct me if Iím wrong):
    div#sporocilo
    Targets just one div on a page with ID sporocilo.

    div.sporocilo
    Targets any div with a class of sporocilo.

    #page
    Does this targets any element with ID page?

    div.generalbox, div.section
    These are grouped together. These targets a div with class generalbox or section.

    .category .course_info
    What does this do?

    table.categorylist td
    This one targets td only inside table with class of categorylist.

    .generalbox h2, #page h2.main,
    These are grouped together. First targets any h2 with class generalbox or targets h2 in an element with class of generalbox? Second targets h2 with class main in what/where?

    What is the difference between h2.main and .main h2?

    #dock div.controls
    What does this do?

    div.sporocilo.box
    What does this do?

    I hope you can help me.


    Bostjan
  2. #2
  3. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    Location
    A Land Down Under
    Posts
    2,066
    Rep Power
    1990
    Originally Posted by Bostjan
    div#sporocilo
    Targets just one div on a page with ID sporocilo.
    Correct.

    Originally Posted by Bostjan
    div.sporocilo
    Targets any div with a class of sporocilo.
    Correct again.

    Originally Posted by Bostjan
    #page
    Does this targets any element with ID page?
    yes, but remember that if you do your HTML right, you should only ever have one element with that ID anywhere on the page. Two or more is invalid according to the specs.

    Originally Posted by Bostjan
    div.generalbox, div.section
    These are grouped together. These targets a div with class generalbox or section.
    Correct.

    Originally Posted by Bostjan
    .category .course_info
    What does this do?
    That targets any element with a class of course_info that's inside an element with a class of category
    Code:
    <div class="category"><ul class="course_info"></ul></div>
    Originally Posted by Bostjan
    table.categorylist td
    This one targets td only inside table with class of categorylist.
    Correct.

    Originally Posted by Bostjan
    .generalbox h2, #page h2.main,
    These are grouped together. First targets any h2 with class generalbox or targets h2 in an element with class of generalbox? Second targets h2 with class main in what/where?
    Again, both of these target H2 tags that are contained inside other elements. The first one is any H2 that's contained inside another element with a class of generalbox and the second one targets a H2 with the class of main that's inside the element with the ID of page.

    Originally Posted by Bostjan
    What is the difference between h2.main and .main h2?
    h2.main is a H2 tag with a class of main, and .main h2 is a H2 tag inside an element with a class of .main

    Originally Posted by Bostjan
    #dock div.controls
    What does this do?
    Again, a div with a class of controls that's inside an element with the ID of dock.

    Originally Posted by Bostjan
    div.sporocilo.box
    What does this do?
    That's a div element that has the class of sporocilo and box on the same element.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    3
    Rep Power
    0

    Smile


    Thank you for the answers. You helped a lot!

IMN logo majestic logo threadwatch logo seochat tools logo