Gaurav
Gaurav

Reputation: 8487

Css class selector

I want to select a div whose class = "c" & id = "i" :

 .c
 {
   color: red;
   border:1px;
   font-size:25px;
   background-color: yellow;
   width:200px;
 }

 <div id="i" class="c">change</div>

now how can i change only the width from class="c" properties for this div?

Upvotes: 2

Views: 78

Answers (3)

Rohit Azad Malik
Rohit Azad Malik

Reputation: 32202

Hey you can do this

#i.c{
width:xxx; //your value
}

Upvotes: 1

Makram Saleh
Makram Saleh

Reputation: 8701

You can do something like this:

.c#i { width:400px }

This changes the width of the div with class c AND id i

Upvotes: 3

Sarfraz
Sarfraz

Reputation: 382909

now how can i change only the width from class="c" properties for this div?

To select a div with class c:

div.c {width: yourValue;}

To change a div with class c AND id i:

.c#i {width: yourValue;}

Upvotes: 1

Related Questions