+ 1
what is the difference between css ID & CLASS selector?
please experts explain this.its important for all who are new.this section should have those explaining .thanks everyone for being in solo learn.
10 odpowiedzi
+ 5
in css / html
every element has different id (unique)
while multiple elements can have same class.
ex
in html
<div id="uid"></div>
<div class="cls"></div>
in css
we use id as
#id{}
ex
#uid{}
we use class as
.class{}
ex
.cls{}
more difference
http://stackoverflow.com/questions/12889362/difference-between-id-and-class-in-css-and-when-to-use-it
+ 2
any element ( img , div ,p ) can have id
but its should not be same.
it will work but you shouldn't do it.
+ 1
so for div only can use id again and again in same page but for others cant.is it?bcs i have tried div in one page with same id again and again but its working so i'm confused
0
id is unique each id can only appear in a HTML file once, whereas class can be repeated in HTML file.
0
Id is always unique
class can be same for many
inheritance goes like this
element-class-id
0
div allows use of id
0
Hi
0
Fill in the blanks to give yellow background color to the element with id="intro", and black text color to the class="mytext":
#intro
{
background-color: yellow;
}
{
color: black;
}
0
#intro
{
background-color: yellow;
}
.mytext
{
color: black;
}
0
Nazmul is right