Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS clarify the id selector

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #22705
    cybershot
    Participant

    I am trying to understand more difficult stylesheets. I have seen selectors that start like this

    Code:
    div#content

    why do they put the div there first

    I have also seen an id on a li tag where in the css they did this

    Code:
    ul li

    I guess what i am trying to get at is if you need to specify the parent tag then go through all the child tags untill you get to the id tag. or is it that if you list the parent and then the children that you are trying to target a specific tag. I tried some experiments but the end result didn’t match what I though i would get.

    does that make any sense?

    #47593
    koewnet
    Member

    Also, if you’re using div#idnamehere, you raise the ID’s specificity by 1. Not much, but sometimes it’s good to be sure.

    If you want to learn more about CSS specificity, I recommend reading this article and then test out the calculator.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘CSS’ is closed to new topics and replies.