labeled-checkbox {
border: dashed red;
}
labeled-checkbox:state(checked) {
border: solid;
}`:state()` CSS pseudo-class / notebook
`:state()` CSS pseudo-class
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
:host(:state(checked))::before {
content: "[x]";
}shadowRoot.innerHTML = `<labeled-checkbox part='checkbox'>Yes</labeled-checkbox>`;question-box::part(checkbox) {
color: red;
}
question-box::part(checkbox):state(checked) {
color: green;
outline: dashed 1px green;
}