+ 3
What do they mean when they say id attribute is unique and can only be used once?
*To make the question clearer Distinguish the one which is correct : And please explain why the other one is wrong! https://code.sololearn.com/WubzbGHUgZ3Z/?ref=app https://code.sololearn.com/WiXzc7200eZh/?ref=app
4 Answers
+ 7
choice A is wrong, use class instead
choice B is correct
+ 7
to see the difference, try use this CSS syntax
use this CSS syntax in choice A:
#paragraph1 {
color: red;
}
use this CSS syntax in choice B:
#paragraph1 {
color: red;
}
#paragraph2 {
color: red;
}
+ 6
a simple explaining
id must unique:
think if id is yourself in this world, only one and different from others.
id can only be used once:
think if id is a number, because number only seen once if you write the numbers from 0 to infinity,
+ 2
If id is unique and can't be used more than once in a document why do we use it then, why not just use class???