Advantages of the "class" and "id" tags for a single html element use use

I am doing an academic academy course and they are asking me to use the left and right column classes, not id. I'm not sure why ...

It seems to me that I will have only one div, which is the left column, and one Div - the right column ... so why should I use the class instead of ID for this?

+4
source share
2 answers

They probably want you to access the element in some way to move it to the left. It is better to use a class, because it is possible that at some point you will want to move another element to the left. If you use id instead of a class, you may need to repeat the same CSS rule for two different elements (different identifiers). Repeating the code is considered bad practice and should be avoided, if possible, at the development level (there is no need to rewrite anything later), so it is suggested to use the class instead of id.

+3
source

, , - Code Academy . - , , . , .

0

All Articles