What are the potential security risks of allowing external websites to pass their own CSS to be displayed on a webpage?

Allowing external websites to pass their own CSS to be displayed on a webpage can pose security risks such as cross-site scripting (XSS) attacks, where malicious code can be injected into the webpage and executed in the context of the user's browser. To mitigate this risk, it is important to sanitize and validate any external CSS input before allowing it to be displayed on the webpage.

<?php
$external_css = "<link rel='stylesheet' href='https://example.com/styles.css'>";
echo htmlspecialchars($external_css);
?>