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

  • SEARCH
  • Home
  • 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 7673235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:27:56+00:00 2026-05-31T16:27:56+00:00

I need a css3 selector to target an element when the :target equals the

  • 0

I need a css3 selector to target an element when the :target equals the id of the element (easy) or when the :target is empty (impossible?). It’s hard to explain, so let me give you a simple example.

div {
  background: blue;
}
div:target, div:no-target {
  background: red;
}

But of course the :no-target pseudo class doesn’t exist ;). Is there a way around this without using Javascript? Thanks in advance!

  • 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-31T16:27:58+00:00Added an answer on May 31, 2026 at 4:27 pm

    Sigh. I feel like I’m resurrecting a dead topic, but it needs a real answer.

    It’s possible to do this with CSS alone, just by using :last-child and a general sibling combinator, in the form of :target ~ :last-child:

    .pages > .page:target ~ .page:last-child,
    .pages > .page {
        display: none;
    }
    
    /* :last-child works, but .page:last-child will not */
    .pages > :last-child,
    .pages > .page:target {
        display: block;
    }
    

    The rules applies in the following steps:

    1. hide all pages
    2. show both targeted page and the last page
    3. if a page is targeted, hide the last page (.page:target ~ .page:last-child)

    (live example)

    Edit: Apparently this is very similar to the accepted answer in an older, previously mentioned, related post.

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

Sidebar

Related Questions

I need to change the font weight of part of a CSS3 content selector.
Do we still need to use the browser prefixes for css3 properties, for example
I have a simple css3 button and I need to align this button inside
I need to flow my text in two columns. CSS3 is't fully implemented by
I need to use, for example, the star-symbol(★) as the bullet for a list-item.
For example, I have some CSS3 code: .iMore:not (.__lod ):active { color: #fff }
I've got a table with CSS3 alternating row styles but I need to override
Do html5 and css3 functionalities depend on the browser (only)? I just need this
I want to use css3 features like box-shadow so for that Do i need
how do you do non-linear animation with css3? Basically, if I need to bring

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.