Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7687383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:41:29+00:00 2026-05-31T19:41:29+00:00

I have a structure like: <div id=holder> <div id=first></div> <div class=box>I’m the first</div> <div

  • 0

I have a structure like:

<div id="holder">
    <div id="first"></div>
    <div class="box">I'm the first</div>
    <div class="box">Nothing special</div>
    <div class="box">Nothing special</div>
    <div class="box">Nothing special</div>
    <div class="box">Nothing special</div>
    <div class="box">Nothing special</div>
    <div class="box">Make this background orange!!!</div>
    <div id="last"></div>
</div>​

I need the last .box element to have an orange background.

.box:last-child{} won’t work because it isn’t the last child. Apart from wrapping only the .box‘s in an element, is there any way to do this? This problem does represent what I’m trying to do, but I’d also like to know if there is a way to match the last matched element of a selector.

http://jsfiddle.net/walkerneo/KUa8B/1/

Extra notes:

  • No javascript
  • No giving the last element an extra class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:41:30+00:00Added an answer on May 31, 2026 at 7:41 pm

    Sorry, aside from abusing sibling combinators or :nth-last-child() in a way that depends fully on your HTML structure1, it’s currently not possible with CSS selectors alone.

    This very feature looks slated to be added to Selectors 4 as :nth-last-match(), though, which in your case would be used like this:

    :nth-last-match(1 of .box) {
        background: orange;
    }
    

    But I don’t know if the syntax is going to change or when vendors will start implementing it, so let’s just leave that as a hypothetical-theoretical-maybe kind of thing for now.


    1 Something like this, given that your last .box is also the second last child:

    .box:nth-last-child(2) {
        background: orange;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

let's say I have an HTML structure like this: <div class=first> <div class=sub-1> <div
I currently have a HTML structure like this: <div id=holder> <div id=content>...</div> <div id=footer>...</div>
i have html structure like this <div> <span class=ic> <span class=ic>12345</span> </span> </div> i
Ok, I have a structure like this: <div class=image> <img src=img1.jpg alt= /> </div>
Ok, so i have a HTML structure like this: <div class=content> <div id=a1 class=article>
I have structure like this <div id=mali_oglasi> <p class=mali_oglas> <span class=name>Predaja7</span> <span class=body>Lorem ipsum
I have a structure like this: <div class=destination>--here needs to copy the value of
If I have a structure like this: <div class=header> <div class=logo>[logo]</div> <div id=navigation class=cf>
I have a structure that looks like this: <div class=project_group> <table> <tr style=display:none> <td>...</td>
I have a DOM structure that looks like this: <div id=comment-1234 class=comment>...</div> <div id=comment-2391

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.