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 8426781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:37:16+00:00 2026-06-10T04:37:16+00:00

I just noticed that CSS :first-child and :last-child don’t work when used on the

  • 0

I just noticed that CSS :first-child and :last-child don’t work when used on the same element. Only one is used. I’m wondering why is that and if there is any workaround to that in CSS? It seems like CSS bug to me – first element can be also last element.

I couldn’t find anything in Google on that subject. Each tutorial assumes that there will be at least 2 elements.

I’m looking for something like: “first child is also last child” selector. Does it exist?

  • 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-06-10T04:37:18+00:00Added an answer on June 10, 2026 at 4:37 am

    I’m wondering why is that and if there is any workaround to that in CSS? It seems like CSS bug to me – first element can be also last element.

    It’s not a bug. It’s how the cascade works: if an element is both the first child and the last child, then if you have :first-child and :last-child in separate rules and they both match the same element, then anything in the later declared or more specific rule will override the other.

    You can find an example of this behavior here, with the border-radius shorthand property, and workarounds that include using the component properties instead of the shorthand, as well as specifying a separate rule altogether using one of the following selectors…

    I’m looking for something like: “first child is also last child” selector. Does it exist?

    Literally, you would chain both pseudo-classes like this, which works fine:

    :first-child:last-child
    

    However there exists a special pseudo-class that acts the same way:

    :only-child
    

    The main difference (in fact, the only difference) between these two selectors is specificity: the first one is more specific as it contains one additional pseudo-class. There is no difference even in browser support, as :last-child and :only-child are both supported by the exact same versions of each browser.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just noticed that Stack Overflow employs Firefox only CSS to round the corners
I've just noticed that Webkit now has some support regarding the CSS Values and
I've just noticed that if I do a MySQL request like this one: SELECT
I have started to use the CSS framework Bluetrip, and I just noticed that
I was just checking out 906.gs css code and noticed that they made all
Just noticed that the sprite used by Gmail for the button backgrounds in the
I'm finishing up my first site: http://www.audio-agent.com/ . I just noticed that, while it
I just noticed that moving the mouse cursor across a tooltip does not seem
I just noticed that java.beans.Introspector getBeanInfo does not pickup any superinterface's properties. Example: public
I just noticed that say http://s7.addthis.com/js/250/addthis_widget.js#pub=PUBID does the equivalent of http://s7.addthis.com/js/250/addthis_widget.js?pub=fct-250 but is much

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.