HTML5/CSS:unable to link .css file with html file

+1 savithri k · April 8, 2015
          I'm trying to run a basic html code with a  basic css code,but my browser is not responding to the code i write in .css file.
         This is the html  code i used:

<!DOCTYPE html>
<meta charset="utf-8" />
  <link rel="stylesheet"   text="text/css"  href="new1.css"/>

below is my  new1.css file:

I'm using firefox browser, and i have ensured that .css file is encoded in utf 8.
Someone please helping me out . I screwed up my entire day on trying to find out the problem with this basic tiny code.
 I really really need help.
Thanks in Advance

Post a Reply


Oldest  Newest  Rating
+1 Rehman . · April 8, 2015

  1. make sure that ".css" file is in the same folder where you have ".html" file

  2. Name of the ".css" file is same as you included in the href="" section, 
    it should work if there is no spelling mistake or file properly placed

0 Charles Wright · April 15, 2015
OK there are a couple things I would like to address concerning both your issue and web design in general.

#1. It looks like you are using HTML5 from the code you posted above. That means you no longer need ending tags. It does not hurt anything to have them but there should be a space and then the ending tag if you DO use them 
<link rel="stylesheet" text="text/css" href="new1.css"/>
<link rel="stylesheet" text="text/css" href="new1.css"> or <link rel="stylesheet" text="text/css" href="new1.css" />

You should create a separate file for your css / media (pics) / javascript instead of having all files in one folder. Your base folder should have just your html (php/asp/etc) files and that is all.

So you have 

/... (whatever else you need)

then you would link  your css with /css/{your css file}

<!DOCTYPE html>
<meta charset="utf-8">
<title>HAWK EYE</title>
<link rel="stylesheet" text="text/css" href="/css/new1.css">




your css file will be in your css folder which is located at the root of your site. So you should have

INSIDE your css folder you would then have new1.css

The only thing else I would mention is your files should represent what they are (main.css / styling.css / etc...)
That should not only fix your issue but get you on your way to programming in an organized manner.

Happy Coding!

-- Zelo
  • 1

HTML / CSS / Web Design


Discuss, share, ask, learn and teach HTML5 and CSS3.