Basic question regarding class and id in html


  • #bgcolor2{
    <-div class=“bgcolor1” id=“bgcolor2”>
    ,<-p> what will be the back ground color?

please ignore all the hyphens
what will be the back ground color and please explain why

Try it on Codepen and you’ll see!

As to why that’s the case, it’s to do with a concept in CSS called specificity. At the most basic level, this means that IDs take precedence over classes, which take precedence over tags.


Use the preformatted text option (from the top tool box in chat box)

or use:

     type in your code here

Then your code will be visible.


Thank you. i have just started html 5

1 Like

That’s Great!!! Don’t be afraid to ask questions, like you just did :thumbsup: as long as you learn something then you’ll be closer to your goal of being a HTML MASTER!!!!!! :fireworks:

1 Like