Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML HTML Forms Choosing Options HTML Forms Review

which attribute is used to group radio buttons element

and how many are they

1 Answer

Hi Hunter,

You're likely looking for the "name" property which sees use for both checkboxes and radio button groups.

Example (using checkboxes):

<form action="#" method="post" class="demoForm" id="demoForm">

    <fieldset>
        <legend>Demo: Checkboxes Sharing Same Name</legend>

    <p>Check the types of sports or fitness activities you engage in on a regular basis.</p>

    <p>
        <label><input type="checkbox" name="sports" value="cycling" /> cycling</label>
        <label><input type="checkbox" name="sports" value="running" /> running</label>
        <label><input type="checkbox" name="sports" value="visit gym" /> visit gym</label>
        <label><input type="checkbox" name="sports" value="swimming" /> swimming</label>
        <label><input type="checkbox" name="sports" value="team sports" /> team sport(s)</label>
        <label><input type="checkbox" name="sports" value="other" /> other</label>
    </p>

    </fieldset>

</form>

I hope this helps.