This forum is now read-only. Please use our new forums at discuss.codecademy.com.
How do I actually link a CSS stylesheet to a HTML sheet?
I am developing a website with Coda 2.
Everything's fine with the html sheet, and with creating a CSS separate sheet. But how do I connect the second with the first?
What should I put in the string:
I suppose I have to substitute the href with my CSS sheet. But how? It is saved on my computer. Should it be online?
as long as your stylesheet is in the same directory as your html file you need this:
<link rel="stylesheet" type="text/css" href="Stylesheet.css" />
but href is short for hyperlink reference, you should have seen before (
<a href="#">), meaning: if your stylesheet is called style.css the link should be:
<link rel="stylesheet" type="text/css" href="style.css" />
(i think this is case sensative)
if you have the css file in a subdirectoy (and the subdirectory is called styledirectory) the link becomes:
<link rel="stylesheet" type="text/css" href="styledirectory/style.css" />
if the css file is in the parent directory of the html file the links becomes:
<link rel="stylesheet" type="text/css" href="../style.css" />
.. goes up 1 directory, if you need two you could do:
this is called relative path (you link relative to html files his location)
there is also absolute path: (for example)
<link rel="stylesheet" type="text/css" href="C:\users\user\style.css" />
or for unix based systems:
<link rel="stylesheet" type="text/css" href="/home/$USER/style.css" />
oops, i am using a unix based system, and you can see that in my answer. if you have windows the slashes in the path are backslashes, not forward slashes (i guess you could say windows goes backwards where unix goes forward (heuheu)
So no, no need to post your stylesheet online, i hope this helps. if you have any further questions feel free to ask