CSS combination selector
Notes:
CSS - Combination selector / Combining selectors:
It is possible to combine a selector with other selectors to make more specific selection
Syntax of CSS rule-set / rule:
selector
{
declaration list;
}
To combine selectors, in place of selector without using any separator; we write selectors one beside another from generic to specific selector
Syntax of Combination selector:
selector1selector2
{
declaration list;
}
Ex:
tagselectorclassselector
{
declaration list;
}
tagselectoridselector
{
declaration list;
}
classselectorattributeselector
{
declaration list;
}
Ex:
h1.redborder
{
border:2px solid red; background-color:cyan;
}
p.redborder
{
border:2px solid red; background-color:yellow;
}
p.redborder[align=”right”]
{
border:2px solid red; background-color:magenta;
}
Interview Questions: