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 trialAnthony Blanton
20,056 PointsWhy not just use anchor tags?
What is the benefit of using link over anchor tags? Because the code below works too right?
<li><a href="/">Home</Link></li>
<li><a href="/about">About</Link></li>
<li><a href="/teachers">Teachers</Link></li>
<li><a href="/courses">Courses</Link></li>
2 Answers
Steven Parker
231,122 PointsThe code above would cause syntax errors due to mismatched tags. The start and end tags of each element must have the sane tag name.
But when correctly coded, a link actually renders into an anchor for the browser. But in the process elements are added to provide visual indications of the active status of the link.
Ian Ostrom
Full Stack JavaScript Techdegree Student 10,331 PointsThe other benefit of using Link tags is that the components will load without a page refresh.
Steven Parker
231,122 PointsThat wouldn't be a "benefit" if you want to add a clickable element to the page. And link tags cannot have any content, and have no end tag.
Anthony Blanton
20,056 PointsAnthony Blanton
20,056 PointsWhoops I meant to change the end tags to an anchor tags as well. It seems though the link component provides extra functionality to the routes. So it makes sense to use it now.