How to make CSS styles dependent on its parent

I was wondering if it is possible to define element styles based on the value of the body identifier.

It's hard to explain, but something like this would be ideal:

HTML:

<body id="home">

CSS

body#home {
  a { /* code here */ }
  p { /* code here */ }
}

body#profile {
  a { /* different code here */ }
  p { /* different code here */ }
}

I know I can do this:

body#home a { /* code here */ }

but it becomes very repetitive.

I will wait for your answers,

Peter

+4
source share
4 answers

, , , CSS, , CSS. , . , , , :

http://thesassway.com/beginner/the-inception-rule

: .

, , . , HTML-, "" " ".

, CSS inline HTML (, ).

+1

, CSS, SASS LESS

, LESS. , .

+3

, #home { ... } .

:

#home .myClass { ... }

, , .

+2

, , - .

:

A <style> , ,

+1

All Articles