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 trialdimitridebeer
4,913 PointsWhen linking a website like facebook or teamtreehouse, do we always use an absolute URL? Would a relative URL even work?
Example: Always this (absolute URL): <a href="http://www.facebook.com"> or is it also possible to do this (relative URL): <a href="facebook.com">
If both can be used, which is better?
1 Answer
Steven Parker
231,248 PointsYour second URL would not reference another site, it would look for a file named "facebook.com" on the current site.
Now you don't always have to specify the protocol (though it is typically done), but you do need to prefix your URL with two slashes to indicate it is another site and not just a file or folder on your own site.
Best practice is to use the full URL (with protocol) when referencing anything not on your own site.