Remove Link Underlines
Modernize your links. While usually done with CSS, this script demonstrates how to iterate through all anchors on a page and strip their text decoration dynamically.
Copy the Script
<!-- CSS Method (Best) -->
<style> a { text-decoration: none; } </style>
<!-- JavaScript Method (Dynamic) -->
<script>
function removeUnderlines() {
var links = document.getElementsByTagName("a");
for (var i=0; i < links.length; i++) {
links[i].style.textDecoration = "none";
}
}
window.onload = removeUnderlines;
</script>
Frequently Asked Questions
Yes. `text-decoration: none` in CSS is the standard, most performant way. The JavaScript method is only useful if you cannot edit the stylesheet directly (e.g., on a restricted CMS).
Removing underlines can hurt accessibility, as colorblind users rely on underlines to identify links. Ensure your links have high color contrast or a distinct style if you remove lines.
Yes. Use `a:hover { text-decoration: none; }` to keep the underline normally but remove it when the mouse passes over.