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

Home Forums CSS Id is not dinamic?

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


    I’ve heard that using id is bad idea, instead of this using class (and :nth-child) is much better for a dinamic site.

    What do you think?

    Can I use class instead of id in every case?


    It depends on what you mean by “dynamic”.

    ID can be used where you need to specifically identify a single element on a page….usually as a javascript hook.

    Otherwise, use a class.

    As for :nth-child or whatever, it will entirely depend on what this issue is.

    There is no need (generally) to add an ID or class to every element. Just the ones that need styling in common and even then it might be possible to use combinator selectors instead.

    Basically, it depends.

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