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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:46:25+00:00 2026-05-22T20:46:25+00:00

I have the following markup: <div class=c1> <div class=c2> <div class=c3> <input> <textarea></textarea> </div>

  • 0

I have the following markup:

<div class="c1">
  <div class="c2">
    <div class="c3">
      <input>
      <textarea></textarea>
    </div>

    <input>
    <textarea></textarea>
  </div>
</div>

I want to match the input and textarea elements from the div.c3 with only one CSS rule. I’m using

div.c1 .c2 .c3 input,textarea { border: 1px solid #f00; }

but this matches all textareas, not only the one cotnained in the c3 div.

Is this possible, or must I write separate CSS selectors for each element?

Look at http://jsfiddle.net/Bp3qn/1/ for the live example.


I updated http://jsfiddle.net/Bp3qn/3/

I only need the input and textarea contained in the c1->c2->c3 containers to be highlighted, not other combinations.

  • 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-22T20:46:25+00:00Added an answer on May 22, 2026 at 8:46 pm

    You don’t need the other elements in the selector, unless you only want to match .c3 if it is within div.c1 .c2:

    .c3 input,
    .c3 textarea {
        /* that's it! */
    }
    

    If you do (per your edit), use this:

    div.c1 .c2 .c3 input,
    div.c1 .c2 .c3 textarea{
        border: 1px solid #f00;
    }
    

    Demo: http://jsfiddle.net/wesley_murch/Bp3qn/6/


    after edit: thats what i’m trying to avoid (my real stylesheet is a lot more complex and css rules are longer, and its getting hard to read)

    In that case, to make things easier just add another class to that .c3 like this:

    <div class="c3 special">
    
    .c3.special input,
    .c3.special textarea{
        border: 1px solid #f00;
    }
    

    Demo: http://jsfiddle.net/wesley_murch/Bp3qn/7/

    If you MUST have the selector as small as possible and there are no other children of .c3.special, just use the star selector (almost never recommended):

    .c3.special * {border: 1px solid #f00;}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following markup for my input fields: <div class=required> <label for=Name>Name <em>*</em></label>
I have the following markup: <div id=routes> <ul id=routesList> <li class=routes>Route 1</li> <li class=routes>Route
If i have the following markup; <div id=container> <div id=box> <div id='sameHeight'>One<br>two<br>three</div> <div id='sameHeight'>four</div>
I have the following (trimmed) markup: <asp:Repeater ID=CostCategoryRepeater runat=server> <ItemTemplate> <div class=costCategory> <asp:Repeater ID=CostRepeater
I have the following HTML markup: <body> <div class=wrapper> <div class=head> <p class=title>title</p> <a
I have the following markup: <div class="header">Text</div> <div class="hiddenArea">sdsada</div> <div class="header">Text2</div> <div class="hiddenArea">sdsada</div> and
I have the following markup: <div class=promo> <p class=preview><a href=#><img src=preview.png></a></p> <p class=caption><a href=/>Project
The following markup will have some extra elements injected into it (i.e.: a div
I have the following markup: <div class=FixedHeightContainer> <h2>Title</h2> <div class=Content> ..blah blah blah... </div>
I have the following markup: <div class=thumb> <img src=thumb.jpg/> <p>Some text here</p> </div> Basically

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.