Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS Bootstrap 4 Basics (Retired) Using Bootstrap Components Adding Buttons and Button Groups

Learning coding
seal-mask
.a{fill-rule:evenodd;}techdegree
Learning coding
Front End Web Development Techdegree Student 9,937 Points

How do I link a page to a button?

I tried to link a separate page (Zuurstoftest.html) to the "Doe de Zuurstoftest" button with a href attribute in different places of the element button. In stackoverflow I didn't find a clear answer. How can I link a page to the button "Doe de zuurstoftest"?

https://w.trhou.se/vmx0sa78k5

1 Answer

andren
andren
28,558 Points

The button element does not support linking to anything by itself, usually when you see buttons that link to a page on a website it is not actually a real button, but an "a" element link that is styled to look like a button.

Since you are using Bootstrap you can achieve the effect you desire by simply changing your button element to be an "a" element keeping the same classes in place, like this:

<a id="buttonz" class="btn btn-primary btn-lg btn-space1" href="Zuurstoftest.html">Doe de zuurstoftest</a>

When Bootstrap sees an "a" element with button classes applied it will style it to look just like a button, so the above element will look just like the current button element does on your website, even though it is not really a button in reality.