/* By default, paragraphs are red. */
p { color: red; }

/* If the paragraph has an anchor in it, it becomes black. */
p:has(a) { color: black; }
<!DOCTYPE html>
<html>
	<head>
		<title>:has()</title>
		<link href="style.css" rel="stylesheet">
	</head>
	<body>
		<p>This is a paragraph without a link in it.</p>
		<p>This is a paragraph with <a href="#">a link</a> in it.</p>
	</body>
</html>