HTML how to open url stored in a variable

2

I am not very knowledgeable in html, I want to open a link that is stored in a variable but without success.

<div class="csgo-item--inspectLink">
      <img src="static/img/inspect.png" href="{{item.inspect}}" target="_blank"style="width:16px;">
</div>

The link is in the variable item.inspect if I put it to show what it has inside the variable it shows the right link but I do not know how to do it when I click on the image open the link in a new tab.

I do not know if it's important but here's the css:

.csgo-item--inspectLink{
 position: absolute;
top: 5px; left: 5px;

padding: 1px 3px;
z-index: 2;

}
    
asked by anonymous 07.11.2017 / 18:29

2 answers

1

In this case you should use the <a></a> tag with the href attribute as follows:

<div class="csgo-item--inspectLink">
      <a href="{{item.inspect}}"><img src="static/img/inspect.png" href="" target="_blank"style="width:16px;"></a>
</div>

href is not an attribute of the <img> tag, but rather the tag here for more information

    
07.11.2017 / 18:32
0

The correct way is you use the link tag first and then put the image inside. Staying like this:

  <a href="{{item.inspect}}"><img src="static/img/inspect.png" target="_blank"style="width:16px;"></a>
    
07.11.2017 / 18:33