+ 2
Why IDs cannot use more than once on a page?
3 Antworten
+ 16
because they are unique to the specific element you are styling. Classes are used for groups of elements. Think of like this: if you are a teacher and you want one student to do something, you use that students name(ID) to direct him. If you want all the boys to do something, you direct them by saying all boys(CLASS) do X.
+ 1
i have been using css for a couple of months now, and i know that you can use an id for more than once on a page but those id can not have the same name. For example if I gave a paragraph element an id called "para" i can not use "para" on any other element on that page, in other words every id on that html document has to have a different name therefore making it unique. As for the class; you can have more than one with the same name. If i gave a paragraph a class called "para", i can use "para" on any other elements on that page.
+ 1
create css file and linking html file
<link href="style.css"rel="stylesheet"type="text/css/>
id how to use #id{color:red}