【问题标题】:Html add links to imageHtml添加图片链接
【发布时间】:2022-07-20 22:51:13
【问题描述】:

我的代码如下。我想添加以将我的网站图标链接到主页,但它似乎不起作用。

$output .= " <img id='svg_logo' href='https://example.com/' src='https://example.com/path/' /> ";

【问题讨论】:

    标签: php html


    【解决方案1】:

    因为&lt;img&gt; 元素没有 href 属性。您不能仅通过添加 href 来将某项内容设为“链接”。

    &lt;img&gt; 是“链接”的内容,链接本身是标准的&lt;a&gt; 元素:

    <a href="https://example.com/">
      <img id="svg_logo" src="https://example.com/path/" />
    </a>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-29
      • 2011-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-10
      • 2014-09-26
      相关资源
      最近更新 更多