Skip to content

Instantly share code, notes, and snippets.

@rusco
Created May 13, 2024 08:17
Show Gist options
  • Save rusco/4c6d3cded12ed1dea9c4b1b41f59f9db to your computer and use it in GitHub Desktop.
Save rusco/4c6d3cded12ed1dea9c4b1b41f59f9db to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en-GB">
<head>
<meta charset="utf-8">
<title>SVG Email Protection</title>
<style>
.svg-email-protection {
width: 180px;
height: 24px;
vertical-align: middle;
}
</style>
</head>
<body>
<p>This is my email: <object class="svg-email-protection" data="svg-email-protection.svg" type="image/svg+xml"></object></p>
</body>
</html>
Display the source blob
Display the rendered blob
Raw
<svg xmlns="http://www.w3.org/2000/svg"
lang="en-GB"
aria-labelledby="title"
viewBox="0 0 200 24">
<title id="title">Email Us!</title>
<defs>
<style type="text/css"><![CDATA[
rect {
width: 200px;
height: 24px;
fill: rgb(255, 255, 255);
}
a:focus rect,
rect:hover {
rx: 4px;
ry: 4px;
fill: rgb(0, 0, 255);
}
text {
font-size: 16px;
fill: rgb(0, 0, 255);
pointer-events: none;
}
a:focus text,
rect:hover + text {
fill: rgb(255, 255, 255);
font-weight: 900;
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
text-decoration: underline 1px solid rgb(255, 255, 255);
text-underline-offset: 5px;
}
]]></style>
</defs>
<a href="mailto:myemail@mydomain.tld" aria-label="Email Us!">
<rect />
<text x="50%" y="50%" text-anchor="middle" dominant-baseline="middle">myemail@mydomain.tld</text>
</a>
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment