1

how can I say that only the first thing should be shown?

.box:nth-of-type(2) {
    display:none;}

makes only the second thing hidden, how can I say "hide everything except the first one"?

Enma Nii
  • 123
  • 1
  • 12

1 Answers1

3

You can use the :not selector with :first-child.

.box:not(:first-child){display:none;}

OR

You can select the first element using the :first-child Selector and give it the properties of display:block;. And add the display:none; property to the other elements

.box:first-child{display:block;}
Ikhlak S.
  • 8,578
  • 10
  • 57
  • 77