Tell me if you need to combine like this:
.top li,article,.top,.number,.comments{margin-bottom:10px} And in what cases is the class used, and in which id? And then I basically only class.
PS Maybe you are advising on optimization?
Tell me if you need to combine like this:
.top li,article,.top,.number,.comments{margin-bottom:10px} And in what cases is the class used, and in which id? And then I basically only class.
PS Maybe you are advising on optimization?
From my own experience I advise you to use id as rarely as possible.
First, in the later stages of development you will already have a set of styles that you may want to use on the page more than once. In the case of id, you will have to either rewrite styles, or duplicate them already for classes.
Secondly, from personal experience, I can say that sometimes I do not notice that, for example, in the jquery sample, I automatically write a dot instead of the hash $ ('. Select') / $ ('# select'). And then I'm looking for a "bug."
Thirdly, the points look neater than the hashes. And if I used Id somewhere as the parent of the rest styles, then it’s not very pleasant to look at the table.
Well, as mentioned above, id is an element identifier, so it should not be repeated. This logic should be followed when you use id, but ultimately it’s not a particularly important goal to select unique elements on the page in this way.
.js-btn-submit, .js-btn-callback and so on. - ferrariWith layout, always type-up everything in classes. At one time, a lot was discussed. It is obvious that later you will transfer this business to the programmer and where he will need to put the IDs where he needs it. Otherwise, you will not remember a kind word. And all these semantic tales about a class are a group of elements, and id is a unique identifier, this is all verbiage. Leave it to people cut off from the real development.
On the contrary, it is better to separate. The id is the id of the item and it must be unique on the page. A class is a set of elements that are combined by a common style set.
I advise myself to start http://htmlbook.ru
*Source: https://ru.stackoverflow.com/questions/405586/
All Articles