views:

47

answers:

3

What are the pros and cons of each? Is there a difference?

CSS Stylesheets in HTML.

+2  A: 

when use http://... (absolute path) you'll need to change it when you move your page to new domain (if you dont generate it dynamically with PHP )

using relative path is the best way imho

using local path is not possible as CSS files are requested by hosts/uests browser, not on server

Tomas Jancik
A: 

It's nice to get started with inline and embedded style="" or putting some style defs in the header, but once a project is more than two pages this just because more work in the end.

Sam
that totally misses the question
Ben
haha, yeah. I am not sure how i read that. I should give myself minus points.
Sam
Thanks anyways though!
Jon Wilson
+3  A: 

I assume you're asking which of these you should use:

<link rel="stylesheet" type="text/css" href="/file.css" />
<link rel="stylesheet" type="text/css" href="http://example.com/file.css" />

The difference between the two is that the former is called a relative path and the latter is an absolute path.

If the HTML page in question is http://example.com/page.html, then there effectively is no difference. However, if the page is https://example.com/page.html (SSL secured), you'll find that there is now a very important difference. On a secured page, many browsers will not load content which is not also served securely. If you've linked your CSS file with an absolute path, it would not be served securely and therefore your stylesheet might not get loaded.

Unless you have a very specific reason to link your CSS absolutely, you want to use a relative path.

josh3736
Thanks! That clears things up quite nicely.
Jon Wilson