You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current spec requires that :empty match any element with nothing inside it, and also any element containing only whitespace. Of course, comments are removed before checking for this whitespace-ignoring emptiness.
The :empty pseudo-class represents an element that has no children except, optionally, document white space characters. In terms of the document tree, only element nodes and content nodes (such as [DOM] text nodes, and entity references) whose data has a non-zero length must be considered as affecting emptiness; comments, processing instructions, and other nodes must not affect whether an element is considered empty or not.
EXAMPLE 48
Examples: p:empty is a valid representation of the <p> elements in the following HTML fragment:
<p></p><p><p></p><p><!-- comment --></p>
div:empty is not a valid representation of the <div> elements in the following fragment:
<div>text</div><div><p></p></div><div> </div><div><p>bla</p></div><div>this is not <p>:empty</p></div>
NOTE: In Level 2 and Level 3 of Selectors, :empty did not match elements that contained only white space. This was changed so that that—given white space is largely collapsible in HTML and is therefore used for source code formatting, and especially because elements with omitted end tags are likely to absorb such white space into their DOM text contents—elements which authors perceive of as empty can be selected by this selector, as they expect.
The text was updated successfully, but these errors were encountered:
The tests for the
:empty
pseudo-class test the behavior of:empty
in selectors level 3, but that behavior is deprecated and was replaced in selectors level 4.The current spec requires that
:empty
match any element with nothing inside it, and also any element containing only whitespace. Of course, comments are removed before checking for this whitespace-ignoring emptiness.However, the tests for the
:empty
pseudo-class expect that:empty
doesn't match elements containing only whitespace (comment optional).This test should be updated to test against the current spec.
Here's the current spec for
:empty
, for convenience:The text was updated successfully, but these errors were encountered: