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

PRARTHITA SAHA
PRARTHITA SAHA
1,009 Points

difference between link element and anchor tag

what is the basic difference between link element and anchor tag. I mean in an anchor tag too we are defining the path of an external document and in link to the same.

Desmond Dallas
Desmond Dallas
6,985 Points

The <link> tag defines a link between a document and an external resource. The <link> tag is used to link to external style sheets. whereas, an anchor tags are generally used for links to other websites.

<a> example: For example if you had a section (text) talking about programming on your blog or website. You may place an anchor tag that links to another website or paragraph of that Website that is relevant to the text on your Website or blog.

4 Answers

Steve Gallant
Steve Gallant
14,943 Points

The <link> element is sort of a behind-the-scenes call to load up a resource that the current page needs to be rendered properly. For example, you might link to your CSS style sheet(s) or to publicly available resources like Google fonts, etc. There is nothing to click on, this is just a shorthand way of making those additional references and resources available when the current page loads.

The anchor <a> element, on the other hand, is how you create user-clickable hyperlinks to other pages (or parts of a page), or protocol links like ftp:// or mailto:

Hope this helps!

Steve

A <link> tag is typically used for linking to other documents, such as a CSS stylesheet. Whereas the <a> tag is used to link to an external page, such as <a href="https://www.youtube.com"></a> would take the user to YouTube.

I love that you can make an make an HTML anchor tag to make an img tag into a clickable hyperlink. The title attribute can be a tool tip link.

I learn a lot at the W3C website's W3school.com. They present a variety of tags and demonstrate with interactive examples.

The <a> tag is used t create hyperlinks between other webpages. Be that on you website or link give the Website user direction to a different website.

The <link> tag is used more behind the scenes for example connecting the CSS file to the HTML file. The Webpage user does not need a to see hyperlink to see how the colour of the font is changed.