dwyl / dwyl/learn-html5

label with nested div?

Open
#43 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
No language data
Stars
35
Forks
8
PR merge metrics
No merged PRs in 30d

Description

I'm trying to make an `input checkbox` checked when clicking on a `div`, something similar to:

```html


Paragraph inside the div




```

My first idea was to wrap the div inside a `label` where the `for` attribute reference the id of the checkbox:

```html


Paragraph inside the div



```
However this is not html valid as label can't have nested element (other than the element targeted by the for attribute, ie the checkbox):
https://stackoverflow.com/questions/20834755/standards-on-behaviour-of-nested-labels

One solution is to use javascript to check the checkbox with a click event handler on the div.

However I'm looking for a solution without javascript.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.