Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New to the CF scene
    Join Date
    Aug 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Am I linking my css wrong?

    Hello all,

    I am completely new to web development and am trying to learn by building my own website. The issue I have run into is getting my css to work on my page.

    HTML:
    <html>

    <head>
    <LINK rel="stylesheet" type="text/css" href="style.css">
    <title> The Shore Report </title>
    </head>

    <body>

    <img src="TheShoreReport.jpg" >

    <img src="Web Background.jpg" >


    </body>

    </html>

    CSS:
    body
    {
    background-color:#b0c4de;
    }

    Is there something wrong with my link or what?

  • #2
    Regular Coder byuhobbes85's Avatar
    Join Date
    Oct 2006
    Location
    Ames, Iowa, USA
    Posts
    116
    Thanks
    9
    Thanked 4 Times in 4 Posts
    Try this.

    Code:
    <link rel="stylesheet" type="text/css" href="style.css" />
    Any tags that do not have an open and a closing tag need to be self-closed like the one above. You also need to make sure that your HTML file and your CSS file are in the same directory.
    -- </byuhobbes>

  • #3
    New to the CF scene
    Join Date
    Aug 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hmm,nope

  • #4
    Regular Coder byuhobbes85's Avatar
    Join Date
    Oct 2006
    Location
    Ames, Iowa, USA
    Posts
    116
    Thanks
    9
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by mwmnj View Post
    hmm,nope
    And what exactly do you mean by "hmm,nope"? What is the issue? I tested the code above (with the modification I suggested) and I see the background color the CSS specified. What are you expecting to see that you don't see?
    -- </byuhobbes>

  • #5
    New Coder
    Join Date
    Aug 2010
    Posts
    19
    Thanks
    0
    Thanked 4 Times in 4 Posts
    or you have your stylesheet outside of the root of the html document. We can't know for sure without knowing what directory the css file is in.

  • #6
    Regular Coder
    Join Date
    Jan 2009
    Posts
    193
    Thanks
    0
    Thanked 20 Times in 20 Posts
    Do you have a link to a live site?

  • #7
    New to the CF scene
    Join Date
    Aug 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The code looks perfect so i suspect it is either an issue with the way i am trying to view my site or the locations of my html/css files.

    The way I am viewing my html file is just by clicking the firefox document it saves as and viewing it in firefox.

    Both .css and .html files are in the same folder on my desktop.

    The background color is white when css is supposed to make it a blue.

  • #8
    Regular Coder
    Join Date
    Jan 2009
    Posts
    193
    Thanks
    0
    Thanked 20 Times in 20 Posts
    If you don't have a link can you attach both files?

  • #9
    New to the CF scene
    Join Date
    Aug 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    My computer saves .html files as firefox documents automatically and it doesn't seem like I can upload it through here.

    here is the text contained inside of my html file though:

    <html>

    <head>
    <LINK rel="stylesheet" type="text/css" href="style.css" />
    <title> The Shore Report </title>
    </head>

    <body>



    </body>

    </html>
    Attached Files Attached Files

  • #10
    Regular Coder
    Join Date
    Jan 2009
    Posts
    193
    Thanks
    0
    Thanked 20 Times in 20 Posts
    Is the style sheet you uploaded the exact name of the file or did you add the .txt file extension? If you didn't add the .txt extension then remove it.


    If I use your style sheet without the .txt extension it works for me.

  • #11
    New to the CF scene
    Join Date
    Aug 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ah, that might be it. How do i remove the .txt? I am trying to resave the .css file with all files instead of .txt but it defaults to .css.txt even when doing that.

  • #12
    New Coder
    Join Date
    Aug 2010
    Posts
    19
    Thanks
    0
    Thanked 4 Times in 4 Posts
    You are probably on a windows machine that is omitting the true extension name. follow these instructions to show the file extensions then just right click and hit rename and delete the .txt

    http://www.fileinfo.com/help/windows...xtensions.html

  • #13
    New to the CF scene
    Join Date
    Aug 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That did the trick. thanks a lot everyone. what a dumb issue


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •