To remove the underline from anchor links in HTML, you typically use CSS. Here's a simple example demonstrating how to remove underlines from all links on your website:
cssa { text-decoration: none; }
If you want to remove the underline for specific links only, add a class to that link and define in CSS that the class should not display the underline:
html<!-- HTML --> <a href="https://www.example.com" class="no-underline">This is a link without underline</a>
css/* CSS */ .no-underline { text-decoration: none; }
Remember to place the CSS code inside the <style> tag within the <head> section of your HTML file, or in an external CSS file, and link it in your HTML using the <link> tag.
For example, using the <style> tag:
html<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Remove Link Underline</title> <style> /* This is the CSS code */ a { text-decoration: none; } </style> </head> <body> <!-- This is the HTML link --> <a href="https://www.example.com">Visit Example.com</a> </body> </html>
Or, using an external CSS file:
- Create a CSS file (e.g.,
styles.css) and add the following CSS code:
css/* styles.css file */ a { text-decoration: none; }
- Link this CSS file in your HTML file:
html<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Remove Link Underline</title> <link rel="stylesheet" href="styles.css"> </head> <body> <!-- This is the HTML link --> <a href="https://www.example.com">Visit Example.com</a> </body> </html>