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) Basic Selectors Class Selectors

Nana Ackah
PLUS
Nana Ackah
Courses Plus Student 1,935 Points

Hi everyone a beginner here, I am trying to link my css sheet to html file but seems not to be working any help?

I'm using Atom as my text editor.

2 Answers

Rich Donnellan
MOD
Rich Donnellan
Treehouse Moderator 27,708 Points

Did you put something like this in the <head> section of your HTML file?

<link rel="stylesheet"  href="{path/to/css/file}">

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

Nana Ackah
Nana Ackah
Courses Plus Student 1,935 Points

Yes I did for some reason I thought the issue was something related to preview so I downloaded a setting on Atom and now I'm getting troubleshooting?!

Shay Paustovsky
Shay Paustovsky
969 Points

Hi Nana,

Linking to an external CSS document is done using the "<link> tag

<link rel="stylesheet" href=""> 

Is a self closing/empty element therefore it doesn't need a closing counterpart tag.

The "rel" attribute describes the current relationship of the document being linked to the current document where it's being linked to.

In this example "stylesheet" value describes that the file being linked is a stylesheet to the current HTML document.

The "href" attribute describes the path to the file in the website's folder structure.

So in conclusion a <link> tag might look like this in a website:

<link rel="stylesheet" href="CSS/stylesheet.css">

This is one of the 3 CSS author rules:

  • External (<link>)
  • Internal (<style></style> - Tags are writted in the 'head' of the document and CSS rules are written between them.)
  • Inline (<style="property:value;")

Hope this helped,

Happy Coding

Shay