Search code examples
htmlhyperlinkhrefembedding

Parent directory(../../) vs http(s):// links in href includes


What is the difference when using

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

rather than using

<link href="http://example.com/css/style.css" rel="stylesheet">
<link href="https://example.com/css/style.css" rel="stylesheet">

Is there any downside?


Solution

  • There's no downside of using the relative links. There're some downsides of using the full links though:

    1. it's longer (obvious!)
    2. you'll have to rewrite all such links in case you move your site somewhere else
    3. you shouldn't really force to use either http or https

    On the other hand, the full link is something you can't escape if you're loading the resource from other domain.