It is not possible to apply CSS styling to a broken link, as the browser does not detect the status of a link until it is accessed by a user or system.
One potential approach could involve using Javascript to attempt to fetch each linked page within the document. If a link fails to load, the script could dynamically alter the link's appearance. However, this method may be inefficient and resource-intensive, especially on mobile devices.
Additionally, accessing links from different domains may be restricted by the browser for security reasons, limiting the effectiveness of the Javascript solution.
A more practical solution would be to have a server periodically check the validity of links on your pages and store this information in a database. The server could then add a class to broken links when rendering the page, allowing CSS to style them accordingly. Server-side processing eliminates same-origin restrictions and provides more reliable link status checks. However, offline evaluations may present challenges, such as temporary server outages or specific internet routing issues.