How do I hide the div “paymentProviderHeader-cc” with JavaScript (not jQuery) but without the help of those classes because there is another section in the page with the same divs/classes that I don’t want to hide. The only unique selector I can use in this case is the attribute for in label (for=“radio-paypalcommerce”).
One thing I did notice — The hidden attribute is overridden by the display property, so if that element has a display set to ‘block’, the hidden attribute will not work. Maybe something to bear in mind.
Off-topic: it would be remiss of me not to say that a label element can’t have divs as children. Block elements are not permitted as children of a label element and they need to be phrasing elements like spans to be valid.
They will do no harm in reality but of course will not validate.
Yes you are probably right, but it does spell out what it is. I would say for the extra few letters/specificity it is quicker and easier to grasp what the element in the selector is.