Hide mail address in html
There are a few ways to hide a mail address in HTML, depending on your specific needs and the level of security you require. Here are a few options:
- Use a mailto link with a JavaScript function: You can create a mailto link that calls a JavaScript function to hide the email address. Here's an example:
<a href="javascript:emailMe('[email protected]')">Contact me</a>
- Use a mailto link with a CSS class: You can add a CSS class to the mailto link to hide it from view. Here's an example:
<a href="mailto:[email protected]" class="hidden">Contact me</a>
-
Use a mailto link with a server-side script: You can use a server-side script to generate a mailto link with a hidden email address. For example, you can use PHP:
<a href="mailto:<?php echo $_GET['email'];?>">Contact me</a>
In this example, the PHP script generates a mailto link with the email address passed as a GET parameter.
-
Use a third-party service: There are several third-party services that can help you hide your email address, such as Gravatar or ReCaptcha. These services can generate a unique email address for each user and forward emails to your actual email address.
Remember to always validate any user input before using it to generate a mailto link, to prevent potential security vulnerabilities.