title: How to make a responsive and interactive Image map using SVG
body: <p>I'm busy with a website and on the home page I need to have two clickable sections one of which takes you to one specialization of the company and the other takes you to their other specialization. </p>
  
  <p>I have created a square image split trough the center making two right angled triangles I need the top one to go to one link when you click on it and the bottom one to go to another link. I did some research and I saw that using <strong>SVG</strong> would be my best bet in achieving this especially since it must be responsive but I have had no luck.</p>
  
  <p>I have tried coding triangles in <code>xml</code> then adding <code>xml:href</code> links to the triangles but this did not work.</p>
  
  <p>I have also tried multiple things with Inkscape but without results, it either makes the clickable location to small or the image becomes unresponsive.</p>
  
  <p>I now have the following thanks to Paul LeBeau:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;body&gt;
  
          &lt;svg viewBox="0 0 400 300"&gt;
  
          &lt;image xlink:href="image.jpg" x="0" y="0" height="100%" width="100%"/&gt;
  
              &lt;a xlink:href="http://www.example.com"&gt;
                  &lt;polygon points="0,0, 400,0, 0,300"/&gt;
              &lt;/a&gt;
  
              &lt;a xlink:href="http://www.google.com"&gt;
                  &lt;polygon points="400,0, 400,400, 0,300"/&gt;
              &lt;/a&gt;
  
          &lt;/svg&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I have to nest it in an html as that is what my server side hosting requires. What happens when I run this code is that it works, its responsive and the links work but the image does not show it only shows a black square.</p>
  
  <p>While trying to figure out a solution I noticed some of the image coming trough the black so I tried the following:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;body&gt;
  
          &lt;svg viewBox="0 0 400 300"&gt;
  
              &lt;a xlink:href="http://www.example.com"&gt;
                  &lt;polygon points="0,0, 400,0, 0,300"/&gt;
              &lt;/a&gt;
  
              &lt;a xlink:href="http://www.google.com"&gt;
                  &lt;polygon points="400,0, 400,400, 0,300"/&gt;
              &lt;/a&gt;
  
          &lt;image xlink:href="image.jpg" x="0" y="0" height="100%" width="100%"/&gt;
  
          &lt;/svg&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Which then shows the Image with some black coming trough but the links do not work.</p>
  
  <p>After thinking on it a bit I decided to split up my triangles into .png images without backgrounds and decided to add them with <code>xml:href</code> and the image tag inside the <code>&lt;a&gt;</code> tags of the triangles and wrapping it all in some positioning CSS. Here is the code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;body&gt;
  
      &lt;style&gt;
      #positioning {
          position: relative;
          float: center;
      }
      &lt;/style&gt;
  
          &lt;div id="positioning"&gt;
  
          &lt;svg viewBox="0 0 400 300"&gt;
  
              &lt;a xlink:href="http://www.example.com"&gt;
                  &lt;polygon points="0,0, 400,0, 0,300"/&gt;
                  &lt;image xlink:href="image1.png" x="0" y="0" height="100%" width="100%"/&gt;
              &lt;/a&gt;
  
              &lt;a xlink:href="http://www.google.co.za"&gt;
                  &lt;polygon points="400,0, 400,400, 0,300"/&gt;
                  &lt;image xlink:href="image2.png" x="0" y="0" height="100%" width="100%"/&gt;
              &lt;/a&gt;
  
          &lt;/svg&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I tried this with and without the CSS I get the same results. This almost works, the triangles are somewhat where they are supposed to be but not completely and the black is also there which is not a problem but it shows that its working which is nice and the whole area is clickable but it only registers the second link (google) no matter where you click and it does not go to the first link (example) at all.</p>
  
  <p>Please any help would be appreciated.</p>