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 trialAaron Boyse
154 Points# link for content?
I am trying to link div classes on a website that I am building and trying to use the # to link them together. How is it possible to do so?
4 Answers
Wilson Usman
35,206 PointsIs this what you're trying to do?
Sample: Link to a section
HTML
<ul>
<li><a href="#link-1">Link 1</a></li>
<li><a href="#link-2">Link 2</a></li>
</ul>
<div>
<a id="link-1">This is link 1</a>
</div>
<div>
<a id="link-2">This is link 2</a>
</div>
CSS
div {
margin-top:200px;
height: 500px;
}
Rafael Ferreira
13,086 PointsThis will do it! But just to clarify, you don't have to put the ID for the anchored section in a <a>
tag.
<div id="link-1">
<p>This is the "anchored" section</p>
</div>
Great answer though!
graymattercreative
Front End Web Development Techdegree Student 11,304 PointsUse an Id instead of a class since it has greater specificity.
Create your link and have it match to corresponding div Id on your page.
Short example: <li> <a href ="#work">Work</a></li>
<div id="work" class="wrk-content"> Your code here </div>
Aaron Boyse
Courses Plus Student 1,924 PointsHow do I post pictures
Abdullahi Abdinasir Ali
9,520 PointsWhile doing the quiz and still paging the coding say get help ask the question pic of u code will be add. Hope that helps
Abdullahi Abdinasir Ali
9,520 PointsBefore u post mark small box that say attach my with the post it is next to start discussion
Martin Zarate
10,723 PointsMartin Zarate
10,723 PointsLink classes? can you show us a code snipet?