0

Is it possible to add multiple classes to a div element? I try to add the full and the b class, but it does not work.

#card { 
/* default for card */
    width: 300px;
    height: 50px;
    padding: 15px;
    background-color: yellow;
    box-shadow: 10px 10px 40px grey;
}

#card.g {
    background-color: lightgreen;
    box-shadow: 10px 10px 40px grey;
}
#card.b {
    background-color: lightblue;
    box-shadow: 10px 10px 40px grey;
}

#card.full{
    width:100%;
    height:100%;
    padding:10px;
}
<h3 id="card" class="full" class="b">Hi!</h3>

I am sorry if this is a bad question, I am new to programming.

Stardust
  • 999
  • 3
  • 12
  • 24

2 Answers2

5

yes, you just put the multiple classes separated by a space. if you put class="" twice in an element, like you did, it will disregard the second one

#card { 
/* default for card */
    width: 300px;
    height: 50px;
    padding: 15px;
    background-color: yellow;
    box-shadow: 10px 10px 40px grey;
}

#card.g {
    background-color: lightgreen;
    box-shadow: 10px 10px 40px grey;
}
#card.b {
    background-color: lightblue;
    box-shadow: 10px 10px 40px grey;
}

#card.full{
    width:100%;
    height:100%;
    padding:10px;
}
<h3 id="card" class="full b">Hi!</h3>
indubitablee
  • 8,136
  • 2
  • 25
  • 49
3

Yes, you can

<h3 id="card" class="full b g">Hi!</h3>
ainu
  • 151
  • 1
  • 1
  • 9