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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:57:42+00:00 2026-05-12T08:57:42+00:00

What I have is a form with one fieldset containing several other fieldsets. For

  • 0

What I have is a form with one fieldset containing several other fieldsets. For each fieldset, the user can check a box next to the legend and expand that fieldset (in theory, at least). I was thinking it would be cool to try using pure CSS for the effect, but I’m getting hung up on how to write the rule based on the two elements position to one another in the DOM. Here’s the HTML:

 <fieldset id="areasofinterest">
     <legend>Areas of Interest Survey</legend>

 <p>Please Check The Areas Applicable to you and Answer the Coorepsonding Questions.</p>

<!--Area 1 Checkbox and Questions -->
<fieldset class="area">
    <legend>
        <input type="checkbox" value="area1" id="area1" />
        <label for="area1"> Area 1 :</label>
    </legend>
    <ul>
        <li>
            <label for="area1_q1">Q1</label>
            <input type="text" name="area1_q1" id="area1_q1" />
        </li>
        <li>
            <label for="area1_q2">Q2</label>
            <input type="text" name="area1_q2" id="area1_q2" />
        </li>
    </ul>
</fieldset>

<!--Area 2 Checkbox and Questions -->
<fieldset class="area">
    <legend>
        <input type="checkbox" value="area2" id="area2" />
        <label for="other"> Area 2 :</label>
    </legend>

    <ul>
        <li>
            <label for="area2_q1">Q1</label>
            <input type="text" name="area2_q1" id="area2_q1" />
        </li>
        <li>
            <label for="area2_q2">Q2</label>
            <input type="text" name="area2_q2" id="area2_q2" />
        </li>
    </ul>
</fieldset>

  </fieldset>

At first the idea seemed a bit hack-ish to me, but I ran it through the w3c validator, and yipiee it passed with inputs embedded within legends. So I’m sure I can get what I’m after using javascript/jquery, but I’d hate to at least have a proof of concept for doing it with CSS, even if older browsers may not support it.

I tried this rule:

.area ul {
    color: red;
 }

 .area input:checked + ul {
    color: blue;
 }

But with no luck. I confirmed with a much simpler test that both browsers I’m working with (Chrome, FF 3.5) can do input:checked + ul if it’s simply an input followed by a ul. And it does toggle colors if I have both rules (in the simplified version).

But I’m not sure if there is a way to refer to the UL if the checked element is whithin the legend tag and thus not a direct sibling of the UL. Is there maybe a way to say “siblings of legends which contain inputs which are checked…”?

Thanks for the help.

  • 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-12T08:57:42+00:00Added an answer on May 12, 2026 at 8:57 am

    Nope.

    “siblings of legends which contain
    inputs which are checked…”

    Your problem is at the “contain” step. You can’t move up the DOM like that. An element can’t be selected in CSS based on children (or the children’s contents or attributes).

    You are also using a form element for visual interaction (and a legend), which is odd. I think you are better off with javascript. I can imagine other CSS-only solutions, but none that I would expect to be browser-compatible enough to trust with hiding and showing forms.

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

Sidebar

Related Questions

I have a form with a few fieldsets. One fieldset has a table of
I have one form with several text fields and one button. When i enter
i have one form which have some input box and some select box. i
I have a form and one of the fields is a check-all-that-applies type field
This is a HTML email. I have two tables inside each other. One set
I have a form with 2 sections, each of which starts out with one
I have a form with several different fieldsets. I have some jQuery that displays
I have a PHP form with several check boxes (not groups) with different names
I have one form in a PHP (5.2.9-1) application that causes IIS (Microsoft-IIS/6.0) to
so here's the problem I have one form, it outputs search results after submit,

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.