Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<style>
.container {
  background-color: tomato;
  color: white;
  padding: 20px;
}
</style>
<body>
<h1>The Element Object</h1>
<h2>The matches() Method</h2>
<p id="demo" class="container"></p>
<script>
const element = document.getElementById("demo");
let text;
if (element.matches(".container")) {
  text = "This element matches the CSS selector";
} else {
  text = "This element does not match the CSS selector";
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>