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 CSS Basics (2014) Getting Started with CSS External Style Sheets

Routine Poutine
Routine Poutine
26,050 Points

Do you ever <link></link> to anything else besides a "stylesheet"?

Hi,

I only know one use for links, which is <link rel="stylesheet"></link>. What other relationships might a link tag have?

Best,

Matt

2 Answers

Good question,

You can also use it for app icons:

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#Providing_icons_for_different_usage_contexts

And I also used it recently for a manifest.json file for a Progressive Web App.

https://developers.google.com/web/fundamentals/web-app-manifest/

I think the description below from the MDN web docs describes its use nicely:

The HTML External Resource Link element (<link>) specifies relationships between the current document and an external resource. This element is most commonly used to link to stylesheets, but is also used to establish site icons (both "favicon" style icons and mobile home screen/app icons) among other things.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

For your question in your title regarding linking other types except for a stylesheet, yes, you can link towards a javascript file for example.

The href attribute is the attribute that link elements use to point towards a file path of a file.

You may also come across the type attribute which you can commonly use the values "text/css" and "text/javascript". The type attribute indicates the type of file that the linked document is.

<link rel="stylesheet" type="text/css" href="css/style.css">

You can find out more info on the link element here:

https://www.w3schools.com/tags/tag_link.asp

Also, I noticed in your example question of the link element that you used a closing tag, link elements are self-closing (empty) tags, they don't use a closing tag.

Rich Donnellan
Rich Donnellan
Treehouse Moderator 27,696 Points

To include JavaScript files, you would use <script>, not <link>.