编码html和css相当新,并希望确保我保持代码清洁并正确关闭标签。 我正在使用html模板并尝试从我的按钮中正确创建链接。
我在Brackets中包装它们的方式在页面上正常工作并且链接正常工作,但是Brackets显示了一些红色标记,这意味着我没有正确包装。
有人可以告诉我我在哪里做错了,因为我想要遵循良好的代码形式向前发展。
非常感谢。
以下按钮的当前代码:
<a href="contact_us.html"<button class="button -blue -bordered"><span class="button--inner">Contact Us</span></button></a>
&#13;
答案 0 :(得分:5)
您需要关闭链接代码:
<a href="contact_us.html">
<button class="button button-blue button-bordered">
<span class="button--inner">Contact Us</span>
</button>
</a>
但我不会用链接包裹一个按钮,而是将链接设为按钮。
<a href="contact_us.html" class="button button-blue button-bordered">
<span class="button--inner">Contact Us</span>
</a>
另请参阅以下评论中的 Our_Benefactors :How to create an HTML button that acts like a link?
答案 1 :(得分:0)
实际上有一个小错误。
您忘记了>
代码的<a>
。
试试这个。
<a href="contact_us.html">
<button class="button -blue -bordered">
<span class="button--inner">Contact Us</span>
</button>
</a>
答案 2 :(得分:0)
你错过了&gt; HREF的支架。
<a href="contact_us.html"> <!-- THIS ONE HERE -->
<button class="button -blue -bordered">
<span class="button--inner">
Contact Us
</span>
</button>
</a>