+ 8
What is the difference between id and class?
How do id and class work??
11 ответов
+ 20
We use ID for single element on page
& we use class for multiple elements in a page.
ID must be unique for item but class not.
We can add more than one class in single item but ID is not.
For eg
<div id="menu" class="menu1 menu2 menu3">
</div>
In css ID define with #
& class define with .
+ 19
id value can be given to only one particular block.
class value can be given to multiple blocks.
+ 12
id must be unique wheather class may not be unique .....more element can be given same class name
+ 11
Id is used to identify certain elements.
Class is used to group elements or give every element with the same class, the same style.
Each id has to be unique while a class can be reused as often as you want to.
e.g
<p id="block1" class="blue-borders"></p>
<p id="block2" class="blue-borders"></p>
+ 9
id is an object, which may contain inside the class.
id is a member of class.
id is inherite by class, It is a data. it must declared inside the class. It is use as tool, Id should unque but it depend on programming languages or script .
+ 6
id and class work to give style into html pages.
some characteristics of id :
- each html can only have 1 id
so, the id have to be unique
some characteristics of class :
- you can use same class in multiple elements
- you can use more than 1 classes in same element
to give style to id in css you use #
to give style to class in css you use .
for example,
#firstLine for id="firstLine"
.lineOne for class="lineOne"
+ 5
id must be unique for one element on page.
but class can be given to many elements(tags) on page. :)
+ 3
id value can be given to only one particular block.
class value can be given to multiple blocks.
+ 2
thanks everybody explaining class and id. I was trying to know actually what these are since basically I am not a programming student but trying to learn here on this app.
0
Please teach me
0
Di