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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Location
    Illinois
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Noob here. External css not working!

    Ok, so I may be new at this, but this is the simplest thing ever and it wont work. I am just messing around trying to figure stuff out and I have my css external sheet

    Title {color:red;font-size:36px;font-family:arial;}
    h1 {color:red;}
    p {color:green;font-size:14px;font-family:arial;}
    body {background-color:cyan;}

    and then my html

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <link rel="stylesheet" type="text/css" href="Styleone.css" />
    </head>
    <body>
    <h1> Welcome to my page</h1>
    <p>blah blah</p>
    </body>
    </html>

    There is no html in the css and I have it down exactly like every example has given but when I try it it doesn't work. Im using chrome if that matters.

    Thanks!

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,870
    Thanks
    6
    Thanked 1,029 Times in 1,002 Posts
    Can you tell us what exactly doesn’t work? As first suggestion I would suggest to always use lowercase names in the CSS and also in file names. Secondly, the first CSS rule doesn’t do anything. You can’t style a title element (in fact, nothing outside of the body element), apart from the fact that you don’t even have one.

  • #3
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts
    First thing is to make sure the file name of your style sheet matches the one you;ve linked too.
    Second, I dont think you can style a title. You can certainly create a div named title and then style that, but I dont see any divs yet in your html.
    Last edited by teedoff; 11-17-2010 at 05:45 PM.

  • #4
    New to the CF scene
    Join Date
    Nov 2010
    Location
    Illinois
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Well, nothing is working. The background isn't cyan and the h1 and p aren't the colors. the style will work if it's an internal but once I change it to the external it just shows a white background with the text.

    and I don't even know why I had the title in there I was just trying stuff out. But yeah.

    Edit: Also, the names do match up I have it saved as cssstyle1 and it is the same in the link.

    I have it saved under "desktop/website/cssstyles/cssstyle1" I only need to link the actual name of the file right?
    Last edited by OGREFCERBLNG2ME; 11-17-2010 at 06:21 PM.

  • #5
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts
    Try this....in your html inside the body tag write it like this:

    Code:
    <body style="background-color: blue;">
    edit...try the background color....that will set your whole page to blue as a test. We can remove it later.
    Last edited by teedoff; 11-17-2010 at 06:22 PM.

  • #6
    New to the CF scene
    Join Date
    Nov 2010
    Location
    Illinois
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Well, if I did that wouldn't that be using internal? I could just use an internal css but I am just trying to figure out why an external won't work.

  • #7
    New to the CF scene
    Join Date
    Nov 2010
    Location
    Illinois
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by teedoff View Post
    Try this....in your html inside the body tag write it like this:

    Code:
    <body style="background-color: blue;">
    edit...try the background color....that will set your whole page to blue as a test. We can remove it later.
    Yeah I did that, styling works inside the html just not when I try to do it externally.

  • #8
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts
    Ok then again...check the file name of your style sheet to make sure you are linking to a stylesheet of the same name.

    Nothing looks wrong with your style rules, other than the title rule which we already discussed and should be removed.

    Also, not only make sure the stylesheet is named the same as the link your trying to use, but make sure its actually saved AS a .css file.

  • #9
    New to the CF scene
    Join Date
    Nov 2010
    Location
    Illinois
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by teedoff View Post
    Ok then again...check the file name of your style sheet to make sure you are linking to a stylesheet of the same name.

    Nothing looks wrong with your style rules, other than the title rule which we already discussed and should be removed.

    Also, not only make sure the stylesheet is named the same as the link your trying to use, but make sure its actually saved AS a .css file.
    Yeah, at first I thought it might of saved it as name.css as the filename not with the extension. I am using text wrangler and I thought maybe it won't save as css files, but the icon for the file says CSS at the bottom. and the name is cssstyle1.css as is in the link also. So Idk what the deal is but its bugging me!

    My first day trying to make a page and can't even get a style sheet working!

    Edit1: actually when I look at the files...it says they are saved as text wrangler text documents even though they have html/css on the icon...could this be the problem?
    Last edited by OGREFCERBLNG2ME; 11-17-2010 at 06:45 PM.

  • #10
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts
    Are you saying the name of your stylesheet is this?
    and the name is cssstyle1.css as is in the link also.
    but in your stylesheet link you reference a stylesheet called:

    <link rel="stylesheet" type="text/css" href="Styleone.css" />

  • #11
    New to the CF scene
    Join Date
    Nov 2010
    Location
    Illinois
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by teedoff View Post
    Are you saying the name of your stylesheet is this?


    but in your stylesheet link you reference a stylesheet called:
    Yeah my bad, I renamed the file and re inserted the link to see if I messed up, but it still didn't work. The names are cssstyle1.css now but I don't know if text wrangler is actually saving them as html/css extensions but as files named .html .css if that's even a possibility?

  • #12
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts
    You should really do some basic learning. There are several good free websites that offer great tutorials to learn some basics. W3schools.com is a great one. You can learn html and css along with many other languages and technologies there. Another good site is Alistapart.com

    Obviously there is something wrong with your naming convention or how and to what your linking too. I think those links I provided will help a great deal. One more thing we can try, since your site is probably not live, is you can take a scrennshot image of each opened file. Your html file and your css file, both opened and post them here as an image.

    Good luck.

  • #13
    New to the CF scene
    Join Date
    Nov 2010
    Location
    Illinois
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by teedoff View Post
    You should really do some basic learning. There are several good free websites that offer great tutorials to learn some basics. W3schools.com is a great one. You can learn html and css along with many other languages and technologies there. Another good site is Alistapart.com

    Obviously there is something wrong with your naming convention or how and to what your linking too. I think those links I provided will help a great deal. One more thing we can try, since your site is probably not live, is you can take a scrennshot image of each opened file. Your html file and your css file, both opened and post them here as an image.

    Good luck.

    I am using w3schools right now. It's only this external css I am stuck on right now. But here are the pics.



  • #14
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts
    Ok then, next question would be where are you saving these two files in relation to each other?

  • #15
    New to the CF scene
    Join Date
    Nov 2010
    Location
    Illinois
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by teedoff View Post
    Ok then, next question would be where are you saving these two files in relation to each other?
    The site is: /Users/JnHart/Desktop/Website/templete1.html

    and the css is: /Users/JnHart/Desktop/Website/Cssstyles/cssstyle1.css


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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