Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Aug 2005
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    link rel for css

    Hey I have a question regarding folder structure and linking to css files.

    My folder layout is like so:

    Site> Home, css, index.html

    :- css> main.css
    :- home>products.html


    In my products file I want to link to the main css file which is one level up then one level down in a different folder. is there a way of linking it quicker than http://www... etc etc


    titaniumbean.
    As far as I can tell you're as guilty as a puppy sitting next to a pile of poo !!

  • #2
    Regular Coder
    Join Date
    Jul 2005
    Location
    Halifax, Nova Scotia, Canada
    Posts
    392
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I believe simply 'site/whatever/main.css' will do the trick.
    Once I thought I was wrong but I was mistaken.

  • #3
    New Coder
    Join Date
    Aug 2005
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That doesn't seem to be working i'll just put the http. no matter.



    titaniumbean.
    As far as I can tell you're as guilty as a puppy sitting next to a pile of poo !!

  • #4
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Have you tried something like

    "../otherfolder/cssfile.css"

    ?

  • #5
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Starting a src, href or css url with / is like starting it with http://www.yourdomain.com/

    e.g.
    Code:
    href="/home.html"
    
    	…is the same as…
    
    href="http://www.yourdomain.com/home.html"
    
    
    
    src="/images/myimage.jpg"
    
    	…is the same as…
    
    src="http://www.mydomain.com/images/myimage.jpg"
    
    
    
    background-image: url(/images/myimage.jpg)
    
    	…is the same as…
    
    background-image: url(http://www.mydomain.com/images/myimage.jpg)
    Last edited by Bill Posters; 08-23-2005 at 06:03 PM.

  • #6
    Regular Coder
    Join Date
    Nov 2004
    Location
    The Netherlands
    Posts
    551
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Browsers read a css file with url's to bg images relative to the location of the stylesheet. Let's say you have a dir with index.htm, and 2 folders, called images and css, when you link to the css file (css/style.css), In that css file the a background could be called like this: body {background: url(../images/body.gif)}

    You don't need a slash to indicate the root of your site.
    CATdude about IE6: "All your box-model are belong to us"

  • #7
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by mrruben5
    Browsers read a css file with url's to bg images relative to the location of the stylesheet. Let's say you have a dir with index.htm, and 2 folders, called images and css, when you link to the css file (css/style.css), In that css file the a background could be called like this: body {background: url(../images/body.gif)}

    You don't need a slash to indicate the root of your site.
    I'd say it's preferable to use the root slash (whether you're in the markup or the css) and walk forward through any directories, rather than step backwards.
    Using the root, you don't have to worry where you are in relation to another directory as you're starting from root every time. It's a more simple and clean approach.
    It also helps standardise your use of href/src/url values throughout the site, which is a good thing, imho.

  • #8
    Regular Coder
    Join Date
    Jul 2005
    Location
    Halifax, Nova Scotia, Canada
    Posts
    392
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I second that notion... with a vengence!
    Once I thought I was wrong but I was mistaken.

  • #9
    New Coder
    Join Date
    Aug 2005
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Bill Posters
    Starting a src, href or css url with / is like starting it with http://www.yourdomain.com/

    e.g.
    Code:
    href="/home.html"
    
    	…is the same as…
    
    href="http://www.yourdomain.com/home.html"
    
    
    
    src="/images/myimage.jpg"
    
    	…is the same as…
    
    src="http://www.mydomain.com/images/myimage.jpg"
    
    
    
    background-image: url(/images/myimage.jpg)
    
    	…is the same as…
    
    background-image: url(http://www.mydomain.com/images/myimage.jpg)


    Awesome cheers.




    titaniumbean.
    As far as I can tell you're as guilty as a puppy sitting next to a pile of poo !!


  •  

    Posting Permissions

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