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

Button Help

Hey guys I have just recently downloaded a CSS Template that I, really like I have already coded the buttons on it and everything, (Example, Added a "News" Button to CSS Layout, I have made HTML code for the "News") How do I make it so when people click that "News" Button that it sends them to my HTML Coded page "News.html" Any help would be greatly appreciated :)

3 Answers

@Bryce - Check out Treehouse's badge on links

If text is more your style read HTML Dog's tutorial on links

After you finish with those resources try and write the HTML to link to the news.html page, if you are still having trouble post your code here.

Bryce,

How are the buttons marked up in html? Are they styled as anchor tags (i.e., <a class="button">News</a>) or are you using the HTML button tag (i.e., <button>News</button)?

If the buttons are styled links, you can simply add the href attribute to your tag:

<a class="button" href="news.html">News</a>

If the buttons are actual button elements, then you might need to use a little bit of JavaScript to tell your browser to redirect itself to the page. An example of this might look something like this:

<button onClick="window.location='news.html'">News</button>

Of course, there are other ways to go about styling buttons, and if you choose to use the onClick attribute, you'll need to keep in mind that the user won't be directed to the subsequent page if his or her browser does not support JavaScript or has JavaScript disabled for security reasons.

Let me know if this helps, or if you need more information about the <button></button> tag.

Best wishes,

J.T.

Thanks so much J.T It worked :) Thanks for the help guys!