CSS Structural pseudoclasses - Part 2

Notes:

CSS - Pseudo Class Selectors (Structural) - Part 2:

3.
selector : first-child
{
declaration list;
}
It selects any HTML element targeted by the selector, if it is the first child of its parent HTML element

Ex:
p: first-child
{
border:2px solid red;
}
It selects any p element, if it is the first child of its parent HTML element

4.
selector : last-child
{
declaration list;
}
It selects any html element targeted by the selector, if it is the last child of its parent html element

Ex:
p: last-child
{
border:2px solid red;
}
It selects any p element, if it is the last child of its parent HTML element

5.
selector : only-child
{
declaration list;
}
It selects any HTML element targeted by the selector, if it is the only child of its parent HTML element

Ex:
p: only-child
{
border:2px solid red;
}
It selects any p element, if it is the only child of its parent HTML element

Interview Questions: