w3resource
HTML exercises

HTML CSS Exercise: Style the element which is not empty

Solution:

HTML Code:

<!doctype html>
<html>
<head>
<title>HTML CSS Exercise - Style the element which is not empty</title>
<style>
.container {
  background: #5ac4ed;
  height: 150px;
  width: 200px;
  margin:10px
}

.container:empty {
  background: #ec8007;
}
</style>
</head>
<body>
<div class="container"><!-- I am empty --></div>
<div class="container">I am not empty</div>
</body>
</html>

Live Demo:

See the Pen style-the-element-which-is-not-empty-answer by w3resource (@w3resource) on CodePen.


Supported browser

Firefox logo Chrome logo Opera logo Safari logo Internet Explorer logo
YesYesYesYesYes

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming


bedava porno