Can you please tell me why with layout you should use classes instead of id? Serious argument not googled ...

    4 answers 4

    Here everything is well written!

    Serious argument * s not googled ...


    • what exactly nonsense? - Jeremen1 2:26 pm
    • Brad that did not googled) - Palmervan

    Generally Class for group, ID for one element, on each page there can be one and the same ID. I do not know what tasks you will solve, there are many ways, they are just different and you can do it as you’re used to, like it, like it’s more convenient.

    • I perfectly understand that the id parameter per page is unique, and you can apply as many classes as you like and to as many elements as you like. By the way, I just got a little salt in what. I think just when using classes, the css file becomes smaller on large projects and it is easier to scale, change such a layout later on. - Jeremen1
    • @ Jeremen1: if you have many of the same type of elements on the page, or worse, they are created dynamically, the class is a much better solution than listing all the id. - VladD 2:53 pm

    Because id is a unique parameter, and classes can be used for several elements.

      One of the advantages of id - an element with a specific id on the page can be only one, therefore you do not need to write a bunch of additional classes. You can simply:

       #block{ display: block; } 


       .wrapper .sidebar .nav .block{ display: block; } 

      That is, you can use it in CSS and JavaScript for quick access to an element if you do not intend to create a second element with the same styles. In all other cases, it is better to use classes.