Search code examples
htmlcssvisual-web-developer

Can we put blocks in blocks in CSS?


I'm new in CSS and I have a question about blocks (actually I don't know how do we name the 'blocks' like #my-id{color: yellow} so if you can also answer that it would be great)

So, I wanted to know if it was possible to specifie how will type of a class comport, it would look like this:

.my-class{
   h1{
      color: yellow;
     }
   p{
      color: blue;
    }
}

I hope you understood what I want to explain, so please answer my two questions!!!


Solution

  • Technically, yes, but not when both blocks are rule sets. (e.g. you can put a rule set inside a media query).

    Some other languages, such as SCSS, which can be transpiled to CSS, allow you to do that, but in CSS it is just invalid.