Search code snippets, questions, articles...

Change Last element style using CSS

You can change the style of the last HTML element of a group using CSS by using pseudo-class :last-child.
ul li:last-child {
    background: #ff0000;
    border: 1px solid #ff0000;

We can use :last-child pseudo-class is used to select the last element of a group of HTML elements. In the above code snippet example, we are changing the CSS style of an <li> element which is the last element of its parent.

Search Index Data (The code snippet can also be found with below search text)

last child CSS
Was this helpful?
Programming Feeds
Learn something new everyday on Devsheet