Difference between div.class and .class

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
Exercise 4 - Position: Absolute

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
In the instructions, it says: “In the example above, the .box-bottom div will be moved down and right from the top left corner of the view. If offset properties weren’t specified, the top box would be entirely covered by the bottom box.” What I don’t understand is why the instructions say “.box-bottom div” when the selector is a class. Is “.box-bottom” and “div.box-bottom” the same thing? If not, can you explain how they are different? I’ve seen several instructions before this one that have done this. Thank You.

The code below was the example they provided.




.box-bottom {
  background-color: DeepSkyBlue;
  position: absolute;
  top: 20px;
  left: 50px;
}

.box-bottom will select all elements with class .box-bottom where as div.box-bottom only select the divs with class .box-bottom

i suspect the exercise says .box-bottom div is because you only have a div with this class

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.