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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:53:56+00:00 2026-06-13T17:53:56+00:00

My web application uses forms laid out as in the example below… First Name

  • 0

My web application uses forms laid out as in the example below…

First Name      [____________]
Last Name       [____________]
Gender          () Male  () Female

The markup I use is something like…

<label for="firstName">First Name</label><input type="text" id="firstName" />
<label for="lastName">Last Name</label><input type="text" id="lastName" />
<label>Gender</label>
<fieldset>
  <legend>Gender</legend>
  <input type="radio" name="sex" id="sex-m" value="m">
  <label for="sex-m">Male</label>
  <input type="radio" name="sex" id="sex-f" value="f">
  <label for="sex-f">Female</label>
</fieldset>

I have the following issues that I don’t know how to solve…

  1. I want to have the WHOLE GROUP of radio buttons labelled like any other field (as in the diagram above), but there is nothing to link the label to (i.e. nothing for its “for” attribute, since each radio in the group has its own label just for the value of the individual radio button) A label without a “for” attribute will not pass accessibility compliance.

  2. The <legend> element of the fieldset seems to duplicate the function of the label. Is this really necessary?

I had thought about styling the <legend> tag to appear as though it’s a label, and dispense with the label altogether for the radio button group, but that seems a bit hacky to me, and will also introduce complexities elsewhere in my code (which relies on <label> elements to do some nifty validation message markup and various other things)

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-06-13T17:53:57+00:00Added an answer on June 13, 2026 at 5:53 pm

    The first part of Ssollinger’s answer is correct:

    The code should be:

    <label for="firstName">First Name</label><input type="text" id="firstName" />
    <label for="lastName">Last Name</label><input type="text" id="lastName" />
    <fieldset>
      <legend>Gender</legend>
      <input type="radio" name="sex" id="sex-m" value="m">
      <label for="sex-m">Male</label>
      <input type="radio" name="sex" id="sex-f" value="f">
      <label for="sex-f">Female</label>
    </fieldset>
    

    When assistive technology hits the male radio button, most will read as: “Gender: male radio button 1 of 2 not selected.”

    Then you could use CSS on the fieldset, legend, the labels and inputs. If memory serves correctly fieldsets can be a bear to style, so i might end up adding a <div> to it:

    <label for="firstName">First Name</label><input type="text" id="firstName" />
    <label for="lastName">Last Name</label><input type="text" id="lastName" />
    <fieldset>
      <legend>Gender</legend>
      <div>
      <input type="radio" name="sex" id="sex-m" value="m">
      <label for="sex-m">Male</label>
      <input type="radio" name="sex" id="sex-f" value="f">
      <label for="sex-f">Female</label>
      </div>
    </fieldset>
    

    Adding this <div> has no accessibility implications.

    Like in the comment in ssollinger’s answer, you could dump the fieldset and legend approach, but you would need to build everything to make it accessible, an example of a build out

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

Sidebar

Related Questions

i have created an mvc3 web application that uses forms based authentication. one part
We are developing a web application that uses forms authentication and the ActiveDirectoryMembershipProvider to
I have a web application that uses a couple of PDF forms to create
I have a C# web forms ASP.NET 4.0 web application that uses Routing for
I have a web forms application that uses entity framework, the application is deployed
I have this .NET web forms application which uses SQl server database, It runs
I am a developer working on an ASP.Net Web Application that uses forms authentication.
In an mvc .net web application that uses forms authentication, how to know the
I have an ASP .NET web application which uses Forms Authentication. Let's call this
My company has a web application hosted on a client's machine that uses forms

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.