- HTML中文网
- 联系QQ:88526
- QQ交流群

- 微信公众号

:empty 选择器
定义和用法
:empty选择器选择每个没有任何子级的元素(包括文本节点)。
浏览器支持
选择器 | ![]() | ![]() | ![]() | ![]() | ![]() |
:empty | 9.0 | 3.5 | 9.6 | 4.0 | 3.2 |
CSS语法:
:empty{ CSS语法; }
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <style> p:empty { width:100px; height: 100px; background:pink; } </style> </head> <body> <p></p> <p>指定空的元素的背景色</p> </body> </html>
点击 "运行实例" 按钮查看在线实例
效果图:
推荐手册