SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    calif
    Posts
    743
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why does this code show the page differently?

    This code:

    Code:
     
    <base href="[var.base_url]/">
    <link href="[var.base_url]/themes/default/css/main.css" rel="stylesheet" type="text/css" media="all" />
    And this code:

    Code:
     
    <base href="[var.base_url]/">
    <link href="../themes/default/css/main.css" rel="stylesheet" type="text/css" media="all" />
    show the page differently. Why? Aren't they pointing to the same css file?

  2. #2
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,888
    Mentioned
    122 Post(s)
    Tagged
    1 Thread(s)
    I'm not quite sure what you're doing here, because [var.base_url] isn't (X)HTML as far as I'm aware, but I would guess that the difference is that ../ refers to the parent directory, which is different to what you've put in the first bit of code.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,810
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The following are equivalent (assuming that [var.bas_url] has a proper absolute address substituted for it in the final HTML:

    Code:
    <link href="[var.base_url]/themes/default/css/main.css" rel="stylesheet" type="text/css" media="all"/>
    Code:
    <base href="[var.base_url]">
    <link href="/themes/default/css/main.css" rel="stylesheet" type="text/css" media="all"/>

    Your second version is equivalent to the following:

    Code:
    <link href="[var.base_url]/../themes/default/css/main.css" rel="stylesheet" type="text/css" media="all"/>
    which since that address is unreachable from HTML is equivalent to not specifying the link tag at all.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •