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 Include External CSS

Whats the specific use of using a <link> tag to connect HTML rather than using an <a> tag?

When connecting to a CSS file why do we use the link tag specifically. I know it says that it connects to other files, but doesn't the a tag also do this?

1 Answer

14,636 Points

The differences lie in how they're used is all.

The <link> tags are used solely within the head and they're only used to show the relationship between the current document and an external resource as well as tell the browser where that resource is located so the browser can reference it. That's why the only two attributes that are mandatory are the rel="" and the href=""

Notice that it's self closing and doesn't provide you with any way of actually showing the element on the page. You can't place content anywhere like with the anchor tag

the <a> element or anchor tags however is specifically for hyperlinks. These do not go in the head and they are not self closing so they do provide space within the full element to place content that the browser will render and show on the document.

<a>content to show on the page as the link goes here</a>

The simplest way to put it is, It's just 'how it is' lol