1

I have two div and I want to apply some css on the first div that has no class or id .How can I do it ??

Html:

<div>some content</div>

<div class="text-1">
Mar
  • 43
  • 6

1 Answers1

4

You can use the :not() selector:

div:not([class]) {
  color: red;
}
<div>some content</div>

<div class="text-1">some more</div>

Basically this says select any div that doesn't have the class attribute.

disinfor
  • 9,771
  • 1
  • 31
  • 40