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

HTML

# 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?

Link classes? can you show us a code snipet?

4 Answers

Wilson Usman
Wilson Usman
35,206 Points

Is 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
Rafael Ferreira
13,086 Points

This 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
seal-mask
.a{fill-rule:evenodd;}techdegree
graymattercreative
Front End Web Development Techdegree Student 11,304 Points

Use 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>

How do I post pictures

While doing the quiz and still paging the coding say get help ask the question pic of u code will be add. Hope that helps

Before u post mark small box that say attach my with the post it is next to start discussion