What are the potential security risks of allowing HTML tags in user-submitted content in PHP?

Allowing HTML tags in user-submitted content can lead to security risks such as cross-site scripting (XSS) attacks, where malicious scripts are injected into the webpage. To mitigate this risk, you can use PHP's `htmlspecialchars()` function to escape special characters in the user input before displaying it on the webpage.

$user_input = "<script>alert('XSS attack!');</script>";
$escaped_input = htmlspecialchars($user_input, ENT_QUOTES, 'UTF-8');
echo $escaped_input;