Jump to content

Calling An External CSS


seasonc

Recommended Posts

Hey guys, am new to css, and i know how embarrassing this question probably is, but am experiencing doing it on my own.I want to know, can't you save a css file on your computer with a .css extension and call it? Or do you need to upload the file to a server or something like that? Because from the article i was reading, it was sort of confusing. I know it's silly but help me out. This is what i did, i saved the file on my computer as: hexysal_stylesheet.css. And on my html document, i used<link rel="stylesheet" href="hexysal_stylesheet.css" type="text/css" /> And this is the external css file:body { margin: 0; padding: 0; padding-top: 10px; text-align: center; } #title { background-color:#FFFFFF; font-family:Agency FB; font-size:48px;+ font-weight:bold; color:#003333; padding:10px; margin-left:46px; } h3 { font-family:Arial; font-size:22px; font-weight:bold; margin-left:35px; } #centered { width: 1000px; text-align: left; border: 0px; padding: 0; margin: 0 auto; } .sidebar-box { background-color:#000000; width:220px; height:600px; border:1px solid gray; overflow:scroll; position:fixed; } But it's not working so am beginning to think that when the article said copy this css file and save, it mean save on your server or something. My question is, can i call an external css i saved on my computer? I know it's funny, pls just help me out after you are done laughing. Thanks guys. ...One of the images shows what the Webpage looks like with external css not responding:... ...The others shows what it looks like with internal css

post-96081-0-74203300-1338195772_thumb.jpg

post-96081-0-40344800-1338196490_thumb.jpg

Edited by seasonc
Link to comment
Share on other sites

You don't need anything special for that. http://www.w3schools...s/css_howto.asp Says

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

EDIT: When you're ready for php and mysql, turn your pc into a localhost at wampserver.com. It's free.

Edited by niche
Link to comment
Share on other sites

Niche: Thanks for replying, but you still haven't answered if it can be done with my computer. That is saving the css file on my computer. Because i have tried over and over and it ain't working. Or is there anything wrong withe the css code above?

Link to comment
Share on other sites

Guest So Called

1. Is your css file in the same directory as the html file? 2. is the link code you stated above in your html file's head section?

Link to comment
Share on other sites

maybe show us the <head> section of your HTML, confirm the file names are correct, and make sure you have the files in relative paths to each other. If you have an error console open in your browser while opening the HTML page, if the path is wrong (and thus the stylesheet can't be loaded at the path specificed by the <link>) then you will see a GET error when the browser tries to open the file.

Link to comment
Share on other sites

@TheScientist: This is what the <head> section of my html doc looks like: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html> <head> <title>Home-My Website</title> <link rel="stylesheet" type="text/css" href="linonexy_stylesheet.css" /> </head> <body> <table width="100%" border="0" margin="center" height="100%" style="backgroud-color:white" align="center"><tr>. NOTE: You might be confused, i know i wrote href="hexysal_stylesheet.css" above. because i was using that initially but later changed. So am not making any mistake with the file name. What i have below is correct and it's the name i saved my external css file with: href="linonexy_stylesheet.css". What do you guys mean by having the files in relative to each other? The html and the css files are not in the same folders. They are not even in the same directories. I was beginning to think that maybe they should be. As the document is now, when i launch or test the project am working on, the contents will display but without any style. But if unlink the external css and place all the style in the <head> section of the document (Internal css) everything works just fine. I have edited my topic above and attach a screenshot of my webpage without the css. Pls help out. Thanks guys!

Link to comment
Share on other sites

That is what is wrong! using href="hexysal_stylesheet.css" means this file will be found at the same location as your html file. if you had css file in a folder 'css' and this folder was at the same location as the html file, you would use href="css/hexysal_stylesheet.css". if you had this css file outside the folder that the html file is in, you would use href="../hexysal_stylesheet.css" if you had this css file in a folder 'css' outside the folder that the html file is in, you would use href="../css//hexysal_stylesheet.css" this is what is meant by file location address being relative to each other '../' in effect takes you out of the current folder you are in.

  • Like 1
Link to comment
Share on other sites

Yeaaaaaaaaaaa. It's working now! Thank you guys. Thank you Dsonesuk. I used href="../css/hexysal_stylesheet.css" and it works. The problem was with the location. Thanks guys.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...