Quote:
Originally Posted by ofaict
I recently downloaded the "free css template" off of Lisa's website. (2createawebsite) I also downloaded coffeecup as my html editor.
So here is my question.
I have the "style" and the "index" files in the same folder. And I have been creating new pages in the same folder (pages-in-original-folder) with no problems. The css formating has been carried to all new pages....all looks great.
Now I want to create a new page that has the address of:
mywebsite.com/pages-in-original-folder/newpage.html
How do I go about doing that so that the css carries to the "newpage.html" page??
Thanks!
-Ofaict
|
Your domain name
mywebsite.com is the index.html file. The other pages are in this folder so they will already be mydomain.com/page.html
If you would like to create a page with this structure
mydomain.com/folder/page.html
You will first need to create a new folder in the same directory as your index.html file. Next you will need to create a new html file inside that folder.
To do this create a new .html file in that folder and paste all of the code from index.html to the .html file (make sure you don't delete any code from index.html just copy it)
So you can now access your new .html file at
mydomain.com/folder/page.html
--
Now because you have a new file inside a folder you will need to change bits of code in the new .html file so they point to your .css file.
First look inside your <head> section and find this line (or something similar)
<link type="text/css" rel="stylesheet" href="style.css" />
Now this is the correct path for any file inside the main directory. For your new .html file inside the folder you created you will need to change that line to this following.
<link type="text/css" rel="stylesheet" href="/style.css" />
or this
<link type="text/css" rel="stylesheet" href="../style.css" />
It's up to you what one you use but I always use the first example. Let me explain a bit.
/ = main directory
../ = 1 folder
So by having /style.css it is saying to the browser, look for the style.css is the main directory.
by having ../style.css it's saying to the browser, look for style.css it will be 1 folder deep.
I recommend using the / because you will not need to change it depending on how many folders your file is in. If you wanted this structure
mydomain.com/folder/folder/file.html
You could use this code
<link type="text/css" rel="stylesheet" href="../../style.css" />
because the style.css is 2 folders away. But it's much easier to use the / instead. The following code will always work no matter where the file is.
<link type="text/css" rel="stylesheet" href="/style.css" />
---
The last code your will need to change is on any images so for example
<img src="image.jpg" />
you should change to
<img src="/image.jpg" />
much like the css line.
--
I hope I helped a bit, let me know if there are any problems.