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>
Link Submit Button Using Anchor Tags In HTML In HTML, linking submit buttons using the Anchor Tag is a simple and dependable approach. Write/Declare a Submit button between the Anchor tag's Starting and Closing tags. Give a Path where you wish to link your Submit Button by using the href property of the Anchor element.
In Resilient Web Design Jeremy Keith talks about 'material honesty'. He says that “one material should not be used as a substitute for another, otherwise the end result is deceptive”. Making a link look like a button is materially dishonest. It tells users that links and buttons are the same when they're not.
Conclusion. In HTML, a button link to another page can be by using the <a> tag, <input> tag, and the <form> tag. A link on a button is get by href=”” attribute of <a> tag. The “type=button” and “onclick=link” attributes are used to create a link on the button.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With