External Css File not working!

Discussion in 'Web Design and Development' started by Hector Domingo, Jan 15, 2010.

  1. Hector Domingo macrumors newbie

    Hector Domingo

    Joined:
    May 2, 2009
    #1
    Hi all,
    can you please take a look at my HTML file where i've tried to use an external css file - the problem is: it just doesn't seem to recognise it :(

    index.html ~

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>

    <title>Patrick Rice</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    <meta name="generator" content="HAPedit 3.1">
    <link href="Style.css" rel="stylesheet" type="text/css">

    </head>
    <body>
    <div id="container">
    <p>
    </p>
    </div>


    </body>
    </html>


    Style.css ~
    body {
    color:#ff0000;
    text-align:center;
    }

    #container {
    color:#0000ff;
    width:900px;
    }

    Please can you tell me why it's not working,
    Thanks
     
  2. miles01110 macrumors Core

    miles01110

    Joined:
    Jul 24, 2006
    Location:
    The Ivory Tower (I'm not coming down)
    #2
    Is your stylesheet in the same directory as index.html?
     
  3. Darth.Titan macrumors 68030

    Darth.Titan

    Joined:
    Oct 31, 2007
    Location:
    Austin, TX
    #3
    How do you know it's not working? That html document has no content.

    The stylesheet you posted only has text color declarations, so without any text on the page you won't know whether it's working or not.

    And like miles said, make sure the path to the CSS file is correct.
     
  4. RonCarr macrumors regular

    RonCarr

    Joined:
    Sep 12, 2007
    Location:
    Tennessee
    #4
    Just a tip: Your meta and link tags are self closing so they should end like this />. There should also be a space after the last character and the close.
     
  5. bootedbear macrumors 6502

    bootedbear

    Joined:
    Sep 13, 2004
    Location:
    Austin, TX
    #5
    Naw. Them's XHTML rules. The DOCTYPE clearly defines HTML. No self closing tags.

    And the space before the close is completely optional and a stylistic choice.
     
  6. kylos macrumors 6502a

    kylos

    Joined:
    Nov 8, 2002
    Location:
    MI
    #6
    bootedbear, you're right about that being necessary for xhtml only. However, iirc, the space before the close is helpful for certain browsers (take a guess) which are easily confused by valid syntax.
     
  7. Yvan256 macrumors 601

    Joined:
    Jul 5, 2004
    Location:
    Canada
    #7
    I might be stating the obvious, but if the files are hosted on a case-sensitive operating system make sure your CSS file is really called Style.css and not style.css or STYLE.CSS, etc.
     
  8. RonCarr macrumors regular

    RonCarr

    Joined:
    Sep 12, 2007
    Location:
    Tennessee
    #8
    I didn't even pay attention to the DOCTYPE. I am just not use to people using HTML over XHTML.
     
  9. a cat *miaow* macrumors regular

    Joined:
    Jun 12, 2007
    #9
    That one... it probably is working but you wouldn't be able to see anything.
    Adding a background color on the DIV is an easy way to check it's working.
     
  10. Kristine macrumors 6502a

    Joined:
    Feb 21, 2005
    Location:
    Australia
    #10
    OP: You should keep your files names in lowercase; Style.css should be style.css. It is not compulsory but just good coding practice.
     

Share This Page