Skip to content

Instantly share code, notes, and snippets.

@gonzomir
Created April 17, 2013 14:54
Show Gist options
  • Save gonzomir/5404958 to your computer and use it in GitHub Desktop.
Save gonzomir/5404958 to your computer and use it in GitHub Desktop.
Clickable SVG image with PNG fallback.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Clickable SVG with PNG fallback</title>
<style>
a { position: relative; z-index: 1; }
a span { display: inline-block; }
a object { position: relative; z-index: -1; }
</style>
</head>
<body>
<h1>Example of clickable SVG image with PNG fallback</h1>
<p>The solution of the problem with clickable <code>object</code> elements is from <a href="http://stackoverflow.com/a/12732030">this answer on Stack Overflow</a>.</p>
<a href="#">
<span>
<object src="image.svg" type="image/svg+xml">
<img src="image.png">
</object>
</span>
</a>
</body>
</html>
@theallseeingi
Copy link

Hi,
In my humble opinion, it should be object data and not object src.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment