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

Home Forums CSS Is it possible to select all instances of an element in a class?

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #32273

    I know it is possible to select all instances of a element in an #id tag.

    ex: #generic-id-tag h1

    But I have had no luck with doing it with a class.

    ex: .generic-class h1

    Is there a trick I am missing or is it just not possible. I have tried searching for a solution but since I am fairly new to CSS I might not be using the right nomenclature in my search.

    Thanks in advance for any help.



    .class h1 { } works just as #id h1 { } does.
    Your issue might be with the ‘weight’ of the compound.

    inline stlye=1k pts.

    So if you have :

    Your css for #id h1 { } (weight 101) will always override .class h1 { } (weight 11).


    DogsGhost has a point – though it’s officially referred to as CSS “Specificity.” Being ‘fairly new’ to CSS I figured the initial response went far above your head – its an advanced concept. Here’s a nice overview of the specificity concept (and now you’ll know what to search for);


    That is a great article you found, and I’m all for giving as much valuable information to people as possible, but I really wouldn’t call it an advanced concept. In the same class where I learned what css even was, I learned about specificity. I would consider it a fundamental.


    Thanks you DogsGhost and aaronsilber. It was a hierarchy issue. I read the article, wiped what I had been working on and recoded it with a better understanding of CSS weight.

    For me, it isn’t whether it is an advance concepts or not, it is more that I am teaching myself CSS through building website concepts. Advanced or not, it is more when I organically run into the problem.

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