Role of CSS :last-child Selector

CSSWeb DevelopmentFront End Technology

Use the CSS :last-child selector to style every <p> elements that is the last child of its parent. You can try to run the following code to implement the :last-child selector

Live Demo

<!DOCTYPE html>
         p:last-child {
            background: orange;
      <p>This is demo text1.</p>
      <p>This is demo text2.</p>
      <p>This is demo text3.</p>
Updated on 22-Jun-2020 15:32:37