I like the $ syntax. It's powerful.
Can somebody explain the slash syntax in the example given?
label:matches(:hover, :focus) /for/ input {Can somebody explain the slash syntax in the example given?
label:matches(:hover, :focus) /for/ input { <label for="first_checkbox">A label</label>
<input type="checkbox" id="first_checkbox" />
<label for="another_checkbox">Another label</label>
<input type="checkbox" id="another_checkbox" />
And css: label:matches(:hover, :focus) /for/ input {
margin: 30px;
}
If the user then hovers the first label (for="first_checkbox") the input (id="first_checkbox") will get an annoying margin.The syntax uses the id named in the for-attribute to connect with the element with the same id.
Not really, although it's a bit weird the `//` operator is a relation (like the space, or `>`). It "just" works sideways (and potentially upwards) instead of selecting strictly downwards.
ul > li > p
ul > $li > p
have the same matching complexity: the browser finds all p on the page, then checks if their parent is a li, then checks if that parent is a ul. The difference (which may or may not require significant work) is that before the check acted as a filter on the originally matched object, whereas now there's a transform/translation.