Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of labels inside legends in radio button fieldsets #653

Open
eetukomsi-avi opened this issue Aug 25, 2022 · 1 comment
Open

Usage of labels inside legends in radio button fieldsets #653

eetukomsi-avi opened this issue Aug 25, 2022 · 1 comment

Comments

@eetukomsi-avi
Copy link

The HTML structure for fieldsets is incorrect.
E.g. https://vrk-kpa.github.io/suomifi-design-system/components/radiobutton/

It uses a structure:

<div id="X">
	<fieldset>
		<legend>
			<label for="X">
				Group title
			</label>
		</legend>
		<div>
			<div>
				<input id="Y">
					<span >
						<svg> ...
						</svg>
					</span>
					<label for="Y">Option title</label>
			 </div>
			 ....
		</div>
	</fieldset>
</div>

Legend element represents a caption for fieldset as a label element represents a caption for form control elements (such as an input).
Therefore using a label inside a legend is unnecessary.

Also, the label inside legend uses a for attribute to associate it with the div element surrounding the fieldset. This doesn't match the HTML specs for the label element as the for attribute's value must be the ID of a labelable element (i.e. form control element, such as an input, NOT a div element).

@danielck
Copy link
Contributor

@riitasointi this continues to be an issue and should be fixed when convenient, even though it does not seem to cause actual issues with AT. It is confusing for consumers of the DS/component library and might be used as an example elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants