This pseudo-class matches elements that have no children. Element nodes and non-empty text nodes are considered to be children; empty text nodes, comments, and processing instructions don’t count as children. A text node is considered empty if it has a data length of zero; so, for example, a text node with a single space isn’t empty.
p:empty will match the first paragraph, but not
the second or third, in this example:
<p></p> <p> </p> <p>Hello, World!</p>
In Firefox versions up to and including 2:
- The selector
body:emptyalways matches the body element.
- The selector continues to match an element even after content has been added dynamically.
In Safari versions up to and including 2, when it appears in an
internal style sheet (using
<style> tags), this
selector will always match. If this selector is used within an external
style sheet, it works as designed.
There are no comments yet.