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