I see your CSS, you thought that the foo text will be inside the input, but not really that's because: <input>
don't need a closing tag so they can't inner foo text
so first a foo text in a span
so with CSS we can easily select it
then I used a CSS COMBINATOR ~
https://developer.mozilla.org/en-US/docs/Web/CSS/General_sibling_combinator
you can write it with ALT126
so if the input is checked ...
...the ~
make us not styling the input itself, but the styling what we want (in this case span
)
EDIT: make sure that everything you want to style is after the input because the ~
can't select the previous elements.
here the code
input[type=checkbox]:checked~span {
text-decoration: line-through;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<label for="1640801145364">
<input type="checkbox" value="foo" id="1640801145364" name="foo">
<span>foo</span>
</label>
</body>
</html>