Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML HTML Links Websites: Part 1

Lindsay Hartfiel
Lindsay Hartfiel
7,274 Points

Using quotes around links

Does anyone know why when I wrote quotes after the anchor tag (<a href="") my links don't work but when I deleted the quotes, they worked? I originally included the quotes as demonstrated in the video, but it didn't work.

Doesn't make any sense, would like to see the actual code.

James Barnett
James Barnett
39,199 Points

It's hard for us to know what's causing the issue you are having if you don't show us your code. For some tips on how to do that, check out the this video for some tips on sharing code on the forum.

5 Answers

James Barnett
James Barnett
39,199 Points

Lindsay Hartfiel -

<html lang=“en”>`
<meta charset="UTF-8">

If you look at this code you'll notice a subtle difference between the quote marks. The type in the first example aren't valid in HTML, this can happen if you type up your code in a program that has word processing features.

Lindsay Hartfiel
Lindsay Hartfiel
7,274 Points

**If I add quotation marks after the = it doesn't link. But as it's currently written, it works. Both html files are in the same folder.

Here is the text for the index.html:

<!DOCTYPE html>

<html lang=“en”>
<head>
        <meta charset="UTF-8">
        <title>My Page</title>  
</head> 
<body>

<p>Our first page</p>
<a href=my_directory/another_page.html> My Link </a><br>

<a href=http://google.com>Take me to Google</a>
</body>
</html>

And here's the text for the another_page.html:

<!DOCTYPE html>

<html lang=“en”>
<head>
        <meta charset="UTF-8">
        <title>My Page</title>  
</head>
<body>

<p>Another page</p>

<a href=../index.html>Go Back</a>


</body>
</html>

Hi Lindsay,

Looking at your code I would say the issue is where you are "pointing" the browser. If both files are in the same directory/folder then your links should look like this:

Jeff

<html>

  <a href="another_page.html">My Link</a>
  <a href="index.html">Go Back</a>

  <!-- When you do this, you are saying go up one directory -->
  <a href="../xxxx.httml">yyyy</a>
  <!-- or this, you are say go down one to the my_directory directory -->
  <a href="directory/xxxx.httml">yyyy</a>

</html>
Lindsay Hartfiel
Lindsay Hartfiel
7,274 Points

Sorry. The another_page.html is in another folder called "my_directory." As far as I can tell everything is pointing to the correct path...it's just a matter of why the link only works without the "" in the anchor tag.

Lindsay Hartfiel
Lindsay Hartfiel
7,274 Points

Thanks, James. I was using textedit on the Mac so I'm not sure why the correct characters aren't working, but I'll look into it.

James Barnett
James Barnett
39,199 Points

> I was using textedit

That would do it, as textedit by default works as a wordprocessor, hence the problem with the quotes.

There is a few steps you need to do to configure textedit for coding HTML

That being said, to make your life easier I'd suggest you use free programming text editor like textwrangler or brackets.