:nth-child(1):nth-last-child(1)<\/code>, but with a lower specificity.<\/p>\ndiv p:only-child {\r\n color: red;\r\n}<\/code><\/pre>\nFor example, if we nest paragraphs within a <div><\/code> like so…<\/p>\n<div>\r\n <p>This paragraph is the only child of its parent<\/p>\r\n<\/div>\r\n \r\n<div>\r\n <p>This paragraph is the first child of its parent<\/p>\r\n <p>This paragraph is the second child of its parent<\/p>\r\n<\/div><\/code><\/pre>\nNow we can style the only <p><\/code> of our first child <div><\/code>. The subsequent <div><\/code> and it’s children will never be styled as the parent container holds more than one child (i.e. the p tags).<\/p>\np:only-child {\r\n color:red;\r\n}<\/code><\/pre>\nWe could also mixin additional pseudo-classes like this example that selects the first paragraph within our nested div and the only-child of div.contain<\/code>.<\/p>\n<div class=\"contain\">\r\n <div>\r\n <p>Hello World<\/p>\r\n <p>some more children<\/p>\r\n <\/div>\r\n<\/div><\/code><\/pre>\ndiv.contain div:only-child :first-child {\r\n color: red;\r\n}<\/code><\/pre>\n:only-child<\/code> won’t work as a selector if your parent element contains more than one child with an identical tag. For example\u2026<\/p>\n<div class=\"contain\">\r\n <div>\r\n <h1>Div Child 1<\/h1>\r\n <p>paragraph1<\/p>\r\n <p>paragraph2<\/p>\r\n <\/div>\r\n\r\n <div>\r\n <h1>Div Child 2<\/h1>\r\n <p>paragraph1<\/p>\r\n <p>paragraph2<\/p>\r\n <\/div>\r\n\r\n <div>\r\n <h1>Div Child 3<\/h1>\r\n <p>paragraph1<\/p>\r\n <p>paragraph2<\/p>\r\n <\/div>\r\n<\/div><\/code><\/pre>\ndiv.contain div:only-child {\r\n color: red;\r\n}<\/code><\/pre>\nThis will result in no divs inheriting the color red as the parent contains more than 1 child (the 3 unnamed divs).<\/p>\n