This forum is now read-only. Please use our new forums at discuss.codecademy.com.

CSS: An Overview Forum

View Course » View Exercise

537 points
524157be548c3531ac002ebf_637797236
Submitted by
Tate
over 3 years ago

Real life linking

I know how to link a CSS document to an HTML document

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

But in real life, I'm not sure how you do it. When you create a website, it's just one regular HTML document, right? how do you make the second CSS document?

Even after you make it, does the <link> tag connect the two files?


0 votes

permalink

it really depend on the program you are using to create your website.
i use visual studio 2012, i can create stylesheets and have to link them, like on codecademy except href is different(i can give my stylesheet any name i like and href then becomes: href="the name of the stylesheet.css", which on codecademy is always stylesheet.css)
i have used jsbin, it does require a link, but the site will make the link, you don't see it and don't have to worry about it.
it is also possible to creat internal stylesheet, simply using:

 <style></style>

hope this answers your question

2727 points
593d545c83696644420003b7_64554016
Submitted by
stetim94
over 3 years ago

4 Comments

524157be548c3531ac002ebf_637797236 Tate over 3 years ago

thanks, by the way, where do you edit your CSS file?

593d545c83696644420003b7_64554016 stetim94 over 3 years ago

in visual studio it is easy to create and edit a stylesheet.
in jsbin there is a button css, it will give you a stylesheet and you can use it and edit it.

else i don't know what you mean

524157be548c3531ac002ebf_637797236 Tate over 3 years ago

Thank you! I got it now.

593d545c83696644420003b7_64554016 stetim94 over 3 years ago

your welcome. good you figured it out


0 votes

permalink

I have been practicing at home using notepad++ to type the code manually, rather than use any applications to assist with this. I feel it helps me retain the knowledge better and gets my brain used to typing out and reading / understanding the code.

From my understanding, to create the CSS document, you would just use a text editor, the same as you would for the HTML file, as mentioned above I am currently using notepad++ but there are others and a regular text editor also works fine.

To create the CSS file type the code into a new file and rename it with a .css extention. I believe this can be any name you wish e.g = myownstylesheet.css

You can then save it in the same folder as your html file and simply refer to it in the usual way <link type="text/css" rel="stylesheet" href="myownstylesheet.css"/>

However if you wanted to store this in a subfolder, say a folder called css then you would type it like this <link type="text/css" rel="stylesheet" href="css/myownstylesheet.css"/>

The css/ part tells the code to look in a subfolder called css.

To put this into context I have a folder in my documents called WWW, I also have a subfolder called css so the folder location would be C:\myusername\mydocuments\www\css - but in websites you use a forward slash to specify a subfolder hence css/myownstylesheet - Also, I dont type www/css/myownstylesheet because the html file I am working on is already in www so I only have to specify the sub folder.

Inevitably I will need to switch to some program to enable me to work faster but while I am learning and trying to understand how all of this works and fits together I am doing it manually.

170 points
52658c74548c3550e7000777_872504764
Submitted by
Iain Donald
over 3 years ago


0 votes

permalink

Hey Tate,
I suggest reading about it on W3C training...@ http://www.w3.org/community/webed/wiki/HTML/Training
specifically, 1. (week one) Create HTML. and 2. (week four) Style Sheet .
Follow the steps, take some time to wrap your head around it.

826 points
5155e092035c35abe80000a4_906370420
Submitted by
Kevin Richardson
over 3 years ago