css link css code example

Example 1: link style css to html

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

Example 2: how to link css to html

<link rel="stylesheet" href="file_name.css">

Example 3: link css with path

/*Typical link CSS code: */
<link rel="stylesheet" href="myStyles.css" type="text/css" />
/*
Absolute: 
The browser will always interpret / as the root of the hostname. 
For example, if my site was http://google.com/ and I specified /css/images.css 
then it would search for that at http://google.com/css/images.css. 
If your project root was actually at /myproject/ it would not find the css file.
Therefore, you need to determine where your project folder root is relative 
to the hostname, and specify that in your href notation.

Relative:
If you want to reference something you know is in the same path on the 
url - that is, if it is in the same folder, 
for example http://mysite.com/myUrlPath/index.html and 
http://mysite.com/myUrlPath/css/style.css, and you know that it will always 
be this way, you can go against convention and specify a relative path 
by not putting a leading / in front of your path, for example, css/style.css.

Filesystem Notations: 
Additionally, you can use standard filesystem notations 
like ... If you do http://google.com/images/../images/../images/myImage.png 
it would be the same as http://google.com/images/myImage.png. If you want 
to reference something that is one directory up from your file, 
use ../myFile.css.
*/

Tags:

Misc Example