Cheung
Cheung

Reputation: 15552

CSS Class by element ID?

I have a following css

#container
{
        border:1px solid black;
}
#container #header
{
    color:blue;
}

#container #footer
{
    color:red;
}

Can i write it as

#container
{
        border:1px solid black;
        #header
        {
            color:blue;
        }

        #footer
        {
            color:red;
        }
}

So the #header and #footer are still select as #container's childs element. Or i need to use some css framework like .LESS ?

Upvotes: 0

Views: 94

Answers (3)

Sarfraz
Sarfraz

Reputation: 382656

Yes only if you use SASS, not possible in vanilla CSS.

Upvotes: 1

Marko
Marko

Reputation: 72222

CSS doesn't support that syntax out of the box, so yes you would have to use .LESS

Upvotes: 0

jtbandes
jtbandes

Reputation: 118671

Nope, CSS doesn't support that. I agree, it would be useful. However, you're right, it looks like LESS supports it.

Upvotes: 1

Related Questions