Having problems linking my html to css


This is my first attempt at creating a website and it hasn't gone well. I have a mac so I'm using textedit. I've tried linking my html to css, but to no avail! Here are the info, hopefully someone can save me. when I save my html i titled it attempt1.html and my css try1.CSS. When saving my css does it have to be style.css or can it be whatever I titled it and apply that in href when I link it?

My html:

<!DOCTYPE html>
<link rel="stylesheet" type="text/css" href="try1.css">
  <title>My first attempt</title>
    <h1>This is my first attempt at creating a webpage</h1>


h1 {
background-color: blue;
color: green;
font-family: Arial;


When you link you CSS style sheet to your HTML you need to make sure that the file name and pathway is written in the href part of the link. It does not have to be style.css.

If your CSS name is try1.CSS and is a local file, you need to include the path to find that file.


I apologize, but I don't quite understand. When I saved my html, I clicked save as, then attempt1.html then save. My CSS as try1.css then saved. what do you mean by file name and pathway? Where can I see that?


file name and pathway means the location where the "try1.css" file is located , should be placed inside href attribute of link tag .


So try1.css is the file name for your CSS. Annoyingly I don't use Mac so not sure how to figure out the file path.


Is your css file in another folder?


when first started, i opened text edit and created a folder index.html. Then i created an html and css and saved it under index.html folder.


Is this how your file structure looks?

Folder -



I made a new one and tried viewing it in firefox and this is what i got.



please post your index.html code :slight_smile:



this is my css file which is try.css


name your html file index.html and not try1.html


okay, i renamed it index.html, but nothing chaged.


check your " " at href.both are not same.


Because they're is a problem with your html syntax you forgot to close your <body> tag.

And also post your css file please


I recreated both your files exactly as they are. Saved try1.html and try.css on the Desktop.
And it works fine.

Try having them both on your Desktop, just to check...?


Yeah , your code is working fine without the closing of body tag ""


I downloaded textwrangler and everything worked fine. I don't know what the issues are with textedit but I tried everything and can't get it to work properly.