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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:42:10+00:00 2026-06-15T10:42:10+00:00

I have a simple CSS3 question regarding to selecting appropriate child node. Here is

  • 0

I have a simple CSS3 question regarding to selecting appropriate child node.

Here is a snippet of current HTML element structure:

<nav>
    <ul>
        <li>
            <a href="#"><div class="adminNavButton"><p>Pages</p></div></a>
            <ul>
                <li><a href="#">Make a new page</a></li>
                <li><a href="#">Manage pages</a></li>
                <li><a href="#">Delete pages</a></li>
            </ul>
        </li>
and more .... </ul> </nav>

In CSS3, I’m trying to select just
<a href="#"><div class="adminNavButton"><p>Pages</p></div></a> using

nav ul li a{
}

However, it selects every children anchor tags including ones under <ul><li>. Do I have to give it a class selector to solve the issue? i.e.

<nav>
    <ul>
        <li>
            <a class="something" href="#"><div class="adminNavButton"><p>Pages</p></div></a>

If you know a technique that works across all browsers, I would appreciate it if you could share it with me.

Thanks in advance,

=================================
Thanks for all your comments guys, :first-child nor :nth-child(1) didn’t work from my main project so I’ve created a new project and tested the method. But it did not work
So here is HTML structure and CSS3.

<!DOCTYPE html>

<html>

<head>
    <meta charset="UTF-8">
    <title>asf</title>
    <style>
        ul li a:first-child{
            color: red;
        }
    </style>
</head>

<body>
    <ul>
        <li>
            <a href="">asf</a>
            <div>
                <a href="">asf</a>
            </div>
        </li>
        <li>
            <a href="">asfd</a>
            <div>
                <a href="">asf</a>
            </div>
        </li>
        <li>
            <a href="">asf</a>
            <div>
                <a href="">asf</a>
            </div>
        </li>
    </ul>
</body>


</html>

hmm heh =/ (p.s. I’ve tested it on Firefox and Chrome browser but didn’t work)

  • 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-15T10:42:11+00:00Added an answer on June 15, 2026 at 10:42 am

    You can use the first-child Pseudo-class:

    nav > ul > li > a:first-child
    {
    
    }
    

    Another option that will do what you want is the > selector:

    nav > ul > li > a
    {
    
    }
    

    The above will only apply to the Pages anchor. The > is the child selector so the element must be a direct child, unlike when using a space which targets all descendants. If you have siblings of Pages then those siblings would also be targeted whereas the first example wouldn’t.

    jsFiddle demo

    From the W3C docs:

    The :first-child pseudo-class represents an element that is the first child of some other element. Same as :nth-child(1).

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

Sidebar

Related Questions

Hopefully a simple question here. I have the following html code: <select id=dropdown> <option
I have a question regarding CSS3 animations/transforms. Typically, I can always find my way
I have some simple CSS3 animations here: http://chooseavirb.com/strat/ . They work fine on Firefox,
I have simple JavaScript snippet: var obrazek = [{nazwa: "Sniadanie", wiek: 100, autor: "Alicja"},{nazwa:
I have created a simple layout with Html and CSS which is like below
I have been researching and learning more and more about HTML 5, jQuery, CSS3,
I just a have simple question. I coded my HTML5 website and used some
I have a simple horizontal CSS3 3D flip effect on two div s which
I have simple html with div and button . Also i have a css
I have a simple animation in CSS3 called tap and untap . I call

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.