CSS nth pseudoclasses - Part 2
Notes:
CSS - Pseudo Class Selectors (nth) - Part 2:
3.
selector : nth-of-type(n)
{
declaration list;
}
It selects any html element targeted by the selector, if it is the nth element of its type in its parent html element
Ex:
p: nth-of-type(2)
{
border : 2px solid red;
}
It selects any p element, if it is the 2nd element of p type in its parent html element
4.
selector : nth-last-of-type(n)
{
declaration list;
}
It selects any html element targeted by the selector, if it is the nth last element of its type in its parent html element
Ex:
p: nth-last-of-type (2)
{
border : 2px solid red;
}
It selects any p element, if it is the 2nd last element of p type in its parent html element.
Interview Questions: