empty Selector - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:empty

Description

The :empty selector selects element that has no children including text nodes.

Example

Select empty <p> elements:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
p:empty {<!--  w w  w  .  ja  v  a2  s.c  o m-->
    width: 100px;
    height: 20px;
    background: #ff0000;
}
</style>
</head>
<body>

<p></p>
<p>A paragraph.</p>
<p>Another paragraph.</p>
<p> </p>
</body>
</html>

Related Tutorials