SVG Links

In this example below you will see how to do a SVG Links with some HTML / CSS and Javascript

You can wrap links around any SVG element. This means you make links in the shape of Minnesota (or Wisconsin) and even style their hover states!

Thumbnail
This awesome code was written by 1Marc, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright 1Marc ©
  • HTML
  • CSS
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>SVG Links</title>
  
  
  
      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  <svg width="600" height="500">
  <g transform="translate(-600, 0) scale(1.5)">
    <a xlink:href="http://minnesota.com">
      <path class="minnesota" d="M 475.23781,128.82439 L 474.78056,120.36535 L 472.95158,113.04943 L 471.1226,99.560705 L 470.66535,89.729927 L 468.83637,86.300584 L 467.23601,81.270889 L 467.23601,70.982869 L 467.92187,67.096282 L 466.10094,61.644615 L 496.23336,61.679886 L 496.55668,53.435202 L 497.20332,53.273541 L 499.46657,53.758523 L 501.40649,54.566825 L 502.21479,60.063281 L 503.66974,66.206379 L 505.28634,67.822984 L 510.13616,67.822984 L 510.45948,69.277928 L 516.76424,69.601249 L 516.76424,71.702835 L 521.61405,71.702835 L 521.93737,70.409551 L 523.06899,69.277928 L 525.33224,68.631286 L 526.62552,69.601249 L 529.53541,69.601249 L 533.41526,72.187816 L 538.75006,74.612723 L 541.17497,75.097705 L 541.65995,74.127742 L 543.11489,73.64276 L 543.59987,76.552649 L 546.18644,77.845933 L 546.67142,77.360951 L 547.96471,77.522612 L 547.96471,79.624198 L 550.55127,80.594161 L 553.62282,80.594161 L 555.23943,79.785858 L 558.47264,76.552649 L 561.0592,76.067668 L 561.86751,77.845933 L 562.35249,79.139216 L 563.32245,79.139216 L 564.29241,78.330914 L 573.18374,78.007593 L 574.962,81.079142 L 575.60865,81.079142 L 576.32226,79.994863 L 580.76217,79.624198 L 580.15007,81.903657 L 576.21135,83.740782 L 566.96557,87.80191 L 562.19083,89.808807 L 559.11928,92.395375 L 556.69437,95.951905 L 554.43113,99.831756 L 552.65286,100.64006 L 548.12637,105.65153 L 546.83308,105.81319 L 542.5053,108.57031 L 540.04242,111.77542 L 539.8138,114.96681 L 539.90816,123.01016 L 538.53212,124.69891 L 533.45058,128.45888 L 531.2205,134.44129 L 534.09225,136.675 L 534.77214,139.90198 L 532.9169,143.14091 L 533.08769,146.88893 L 533.45655,153.61933 L 536.4848,156.62132 L 539.8138,156.62132 L 541.70491,159.75392 L 545.08408,160.25719 L 548.94324,165.92866 L 556.03053,170.04541 L 558.17368,172.92053 L 558.84483,179.36004 L 477.63333,180.50483 L 477.29541,144.82798 L 476.83817,141.85589 L 472.72296,138.42655 L 471.57984,136.59757 L 471.57984,134.9972 L 473.63744,133.39685 L 475.00918,132.02511 L 475.23781,128.82439 z"></path>
    </a>
    <a xlink:href="http://wisconson.com">
      <path class="wisconson" d="M 615.06589,197.36866 L 614.99915,194.21124 L 613.82004,189.68474 L 613.1734,183.54165 L 612.04178,181.11674 L 613.01174,178.04519 L 613.82004,175.1353 L 615.27499,172.54874 L 614.62834,169.15387 L 613.9817,165.59734 L 614.46668,163.81907 L 616.40661,161.39416 L 616.56827,158.64593 L 615.75997,157.35265 L 616.40661,154.76608 L 615.95409,150.59537 L 618.70232,144.93726 L 621.61221,138.14752 L 621.77387,135.88427 L 621.45055,134.91431 L 620.64224,135.39929 L 616.43907,141.70405 L 613.69084,145.74556 L 611.75092,147.52383 L 610.94262,149.78707 L 608.98767,150.59537 L 607.85605,152.5353 L 606.4011,152.21198 L 606.23944,150.43371 L 607.53273,148.00881 L 609.63431,143.32065 L 611.41258,141.70405 L 612.40341,139.3462 L 609.84296,137.44486 L 607.86814,127.07787 L 604.32067,125.73589 L 602.37441,123.42756 L 590.2447,120.70592 L 587.36881,119.69387 L 579.15569,117.52658 L 571.23777,116.36783 L 567.47261,111.23716 L 566.72221,111.79117 L 565.5243,111.62951 L 564.87765,110.49789 L 563.54364,110.79444 L 562.41201,110.9561 L 560.63375,111.92606 L 559.66378,111.27942 L 560.31043,109.33949 L 562.25035,106.26794 L 563.38197,105.13632 L 561.44205,103.68138 L 559.34046,104.48968 L 556.43057,106.4296 L 548.99419,109.66281 L 546.0843,110.30945 L 543.17442,109.82447 L 542.19269,108.94622 L 540.07599,111.7814 L 539.84737,114.52487 L 539.84737,122.9839 L 538.70425,124.58427 L 533.44593,128.47084 L 531.15971,134.41503 L 531.61695,134.64365 L 534.1318,136.70126 L 534.81766,139.90198 L 532.98868,143.10269 L 532.98868,146.98928 L 533.44593,153.61933 L 536.41802,156.59143 L 539.84737,156.59143 L 541.67635,159.79215 L 545.10568,160.24939 L 548.99227,165.96496 L 556.07957,170.08017 L 558.13717,172.82364 L 559.05167,180.25388 L 559.73753,183.5689 L 562.02376,185.16926 L 562.25238,186.541 L 560.19478,189.97033 L 560.4234,193.17106 L 562.93825,197.05764 L 565.4531,198.20075 L 568.42519,198.65799 L 569.76753,200.03811 L 615.06589,197.36866 z"></path>
    </a>
  </g>
</svg>
  
  

</body>

</html>

/*Downloaded from https://www.codeseek.co/1Marc/svg-links-lofLH */
svg a:hover path {
  stroke-width: 1;
  stroke: black;
  fill: #555;
}
.minnesota {
  fill: #ccc;
}
.wisconson {
  fill: #999;
}

Comments