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 trialRoutine Poutine
26,050 PointsDo 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
martinjones1
Front End Web Development Techdegree Graduate 44,824 PointsGood question,
You can also use it for app icons:
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
Treehouse Project ReviewerFor 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
Treehouse Moderator 27,696 PointsTo include JavaScript files, you would use <script>
, not <link>
.
Routine Poutine
26,050 PointsRoutine Poutine
26,050 PointsThanks!