Browsing the MDN docs to see the status of a proposed pseudo-class, I came across :required
(and by extension, :optional
). Both of these have been around for a long time but I've only just learnt about them now.
How does this selector differ from using the attribute selector, [required]
. Does it differ?
input:required
or input[required]
. I'll admit that input:optional
is nicer than input:not([required])
.
If it doesn't differ in any way, which should be used or does it not matter at all? Why were these two introduced when attribute selectors are around?