SVG et <a/> , some tests

The class names shown are from my cross browser compatible css snippet

The first link (zebra) goes to my first experiments

1. <a/> with class.my-svg-container

Yes, it's possible, with the help of a <span> absolutely positioned and "hidden" with opacity: 0

My article title

Object <object class="my-svg" >

HTML


  <a class="my-svg-container" href="./" >
    <object class="my-svg" type="image/svg+xml" data="zebra.svg" width="100%" height="100%">
      <img src="zebra.png" />
	  <!-- fallback with png image for browsers with NO SVG support -->
    </object>
    <span>My article title</span>
  </a>

CSS


.my-svg-container{
  display: inline-block;
  position: relative;
  width: 50%;
  padding-bottom: 60%; /* depends on svg ratio, for my zebra height/width = 1.2 so padding-bottom = 50% * 1.2 = 60% */
  z-index: 1;
  vertical-align: middle; /* do what you want */
}

.my-svg{
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%; /* only required for <img /> */
  z-index: -1000;
}

.my-svg-container span{
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  opacity: 0;
}

2. <a/> inside .svg file

I've wrapped the <path> with <a class="svglink" xlink:href="./" target="_top" >

Don't forget xmlns:xlink="http://www.w3.org/1999/xlink" into the <svg> tag

With a little animation on mouse out... just for fun ; ) (js inside svg)

39198