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

Olugbenga Ajayi
PLUS
Olugbenga Ajayi
Courses Plus Student 1,885 Points

Can a hypertext ref be used to link an element to a specified id and an html file?

Here goes:

The premise for the question is as follows I’m currently in the process of creating a new page using an element.

The goal is to be able to click on the ‘See the wildlife’ element seen below and it becomes a new page.

Right now the html code underneath 'See the wildlife' is as seen below

<a class="callout" href="#wildlife">See the Wildlife</a>

To add the new page I could go this route:

<a class="callout" href="See the wildlife.html">See the Wildlife</a>

But I’d like to keep #wildlife when I tried to using

<a class="callout" href="See the wildlife.html" "#wildlife">See the Wildlife</a>

It doesn’t work, is there anything I could do to generate a new page while keeping "#wildlife"

Mitchell Springer
Mitchell Springer
2,576 Points

It may help if you could copy some of your code over so we can have a better idea of what you are trying to do.

3 Answers

TJ Egan
TJ Egan
14,420 Points

"To do this I could easily do this html <a class="callout" href="See the wildlife.html">See the Wildlife</a> But I’d like to keep #wildlife when I tried to using html <a class="callout" href="See the wildlife.html" "#wildlife">See the Wildlife</a> It doesn’t work, is there anything I could do to generate a new page while keeping "#wildlife" "

Yup, you sure can. Try this

<a class="callout" href="See the wildlife.html" id="wildlife">See the Wildlife</a>
TJ Egan
TJ Egan
14,420 Points

Not quite sure what you're asking, but if you are asking if you can make any part of your website a clickable link, and open in a new window, it would be as follows:

<a href="Your website path here" target="_blank">
   <span>
      See the Wildlife
   </span>
</a>
Olugbenga Ajayi
PLUS
Olugbenga Ajayi
Courses Plus Student 1,885 Points

I'm trying to add my code into my question but its not showing up, any tips ?

TJ Egan
TJ Egan
14,420 Points

Wrap your code with 3 backticks (```) on the line before and after. If you specify the language after the first set of backticks, that'll help us with syntax highlighting.

        ```html
        <p>This is code!</p>
        ```