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 How to Make a Website Creating HTML Content Use the Navigation Element

Tomasz Sporys
Tomasz Sporys
11,258 Points

which way is right implementing <a> elements?

I have two options building clickable elements. No matter if its Navigation elements or any other. I don't know what is right? Let's for instance use ul: Should a element be nested inside li or the other way round? Could you please tell me how I should use it?

3 Answers

Daniel Kurowski
Daniel Kurowski
11,231 Points

Hey, Tomasz "li" it's an element which is part of a list, so link should be nested inside it. Think about it like that:

  • "ul" is a table
    • "li" is a chair
  • and "a" is a guest sitting on this chair. Without chair couldn't sit :)

So: ul

li > a

That's the way I do it.

Hope could help.

Harry James
Harry James
14,780 Points

+1 for this analogy :) Great way of thinking about it!

Rasbin Rijal
PLUS
Rasbin Rijal
Courses Plus Student 10,864 Points

Hi Tomasz,

The <a> tag defines a hyperlink, which is used to link from one page to another.

The most important attribute of the <a> element is the href attribute, which indicates the link's destination.

By default, links will appear as follows in all browsers:

An unvisited link is underlined and blue A visited link is underlined and purple An active link is underlined and red

Code syntax :

<a href="http://www.teamtreehouse.com">Visit treehouse website! </a>
Jereld Koh
Jereld Koh
2,251 Points

Hi, I'm new to HTML so it would be great if you could clarify some of my doubts! :)

Is it true that all hyperlinks are included with an <a>? Is it true that all hyperlink references has to come first before the clickable elements?

your help would be much appreciated!

Daniel Kurowski
Daniel Kurowski
11,231 Points

Thanks Harry :) sometimes it's helpful to visualise things