8

Fairly new to coding html and css and want to make sure I'm keeping my code clean and closing tags correctly. I'm working with an html template and trying to correctly create links from my buttons.

The way I've wrapped them in Brackets is working properly on the page and the links are working correctly, but Brackets is showing some red tags meaning I've not wrapped something properly.

Could someone show me where I'm doing this incorrectly, as I'd like to follow good code form moving forwards.

Thanks so much.

Current code for the button below:

 <a href="contact_us.html"<button class="button -blue -bordered"><span class="button--inner">Contact Us</span></button></a>

3 Answers3

16

You need to close your link tag:

<a href="contact_us.html">
  <button class="button button-blue button-bordered">
    <span class="button--inner">Contact Us</span>
  </button>
</a>

BUT I wouldn't wrap a button with a link and instead style the link as a button.

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"/>
<a href="contact_us.html" class="btn btn-primary">Contact Us</a>

Also look at this answer as Our_Benefactors stated in the comments: How to create an HTML button that acts like a link?

lumio
  • 7,428
  • 4
  • 40
  • 56
0

There is a small mistake actually.

You forget > for <a> tag.

Try this.

 <a href="contact_us.html">
   <button class="button -blue -bordered">
       <span class="button--inner">Contact Us</span>
   </button>
</a>
Suresh M Sidy
  • 113
  • 1
  • 11
0

You are missing a > bracket for the HREF.

<a href="contact_us.html"> <!-- THIS ONE HERE -->
     <button class="button -blue -bordered">
         <span class="button--inner">
              Contact Us
         </span>
      </button>
</a>
Ben Temple-Heald
  • 708
  • 1
  • 6
  • 16