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

TextMate HTML & CSS

Hey! I'm trying to use TextMate for MAC to link my html file and css file. I'm doing a practice webpage with the theme of Halloween, just for fun ;). How can I get these two documents to link? I'm trying to use the separate stylesheet approach. I put a link element in the <head> element right underneath the title. Still no luck. My GOAL (and any advice on this would be appreciated, too), is to do a background image on my site. I'm basically exploring with web design to learn as much as I can.

Thank you very much!

4 Answers

Michael Hulet
Michael Hulet
47,913 Points

The text editor you use doesn't matter, just the code that you're writing 🙂 Let's say I have an HTML file in the same folder as another folder called css, and in that css folder, I have a file called style.css. Let's say I want that style.css file to apply to my HTML file. Given this folder structure, I'd put this in my <head> tag:

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

The folder structure here is important, and if you post some code and describe it a bit, I can help a bit more with specifics

As for the background image, this one's probably pretty simple:

html {
    background: url("path/to/your/background/image.png");
    background-size: cover;
}

That gets your <html> tag (which should wrap your whole page), gives it a background image that you can specify, and makes that image take up the whole background

Thank you! I'll give that a shot and let you know if I have any more questions.

I guess my one question is, what does it mean to have the .html file and .css file in the same "folder"?

Thanks, a lot!

Michael Hulet
Michael Hulet
47,913 Points

I'm referring to folders on your computer's filesystem. Some operating systems call them "directories", however

Ok! So if I save the CSS and HTML inside the same folder icon on my MAC, that's what you're referring to? :)

Michael Hulet
Michael Hulet
47,913 Points

Yup, exactly. That way, you can reference it in your HTML file like this:

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

Sweet! Very helpful.