0

I was reading documentation about Angular Material and I ran into this:

.column-login {

    padding: 16px;

  div {
    background: #f5f5f5;
    border: 1px solid #000;
    padding: 50px;
    margin: 16px 0;
  }
}

And it seemed to me a little bit weird. I'm using Visual Studio Code and it shows a bunch of errors there just as I was expecting.

But the code works perfectly. Now, is there any equivalent to that piece of css code?

Because I tried:

.column-login {

    padding: 16px;
}

.column-login > div {
    background: #f5f5f5;
    border: 1px solid #000;
    padding: 50px;
    margin: 16px 0;
  }

And:

.column-login {

    padding: 16px;
}

.column-login div {
    background: #f5f5f5;
    border: 1px solid #000;
    padding: 50px;
    margin: 16px 0;
  }

But it broke. It only works with the first piece of code I just showed you. But I don't know, it seems to me so weird. Can anybody explain me why is it correct?

Rafael Barón
  • 27
  • 1
  • 5

1 Answers1

1

Nested rules is not valid CSS, but it is a feature of a CSS preprocessor program like Sass - it generates valid CSS when compiled.

Your sample generates the following from Sass:

.column-login {
  padding: 16px; 
  }
.column-login div {
  background: #f5f5f5;
  border: 1px solid #000;
  padding: 50px;
  margin: 16px 0; 
  }
DaveStSomeWhere
  • 2,475
  • 2
  • 22
  • 19