13 Replies Latest reply: Feb 9, 2014 5:19 AM by kutukde123 RSS

    a basic questions on file paths

    westwm Community Member

      hi everyone, just trying to get back into the revamping our workplace website, stripping out the old flash based site and implementing a nice smooth css controlled site.

       

      i've gone through the creating your first website tutorial by David Prowse and found it to be very informative but still leaves me with a number of questions. Is there an actual thread present to ask questions based on the materials presented in the 6part tutorials?

       

      a simple question on file paths:

       

      is. <link href="./styles/main.css" the same as

          <link href="styles/main.css" ?

       

      which one is better (foolproof) for uploading to a webspace and which format should be used for all filepath declarations (css, js, scripts etc)?

       

      Btw, what is the difference between

       

      styles/main.css

      /styles/main.css

      ./styles/main.css

      ../styles/main.css ?

       

      thanks for any help

        • 1. Re: a basic questions on file paths
          mytaxsite.co.uk CommunityMVP

          westwm wrote:

           

           

           

          is. <link href="./styles/main.css" the same as

              <link href="styles/main.css" ?

           

          which one is better (foolproof) for uploading to a webspace and which format should be used for all filepath declarations (css, js, scripts etc)?

           

          Btw, what is the difference between

           

          styles/main.css

          /styles/main.css

          ./styles/main.css

          ../styles/main.css ?

           

          thanks for any help

           

          Let me be the first to start here:

           

          1)

          is. <link href="./styles/main.css" the same as

              <link href="styles/main.css" ?

           

          No it is not the same.  The first goes to the root folder and looks for styles folder and then main.css file;  The second simply looks for the styles folder in the same folder as the html page in which this is defined.  so this is at the same level as the document.

           

           

          Which one is better?  It depends on your site definition and the best thing is to let DW decide how to link the file.  Dw is pretty good at getting things right such as this one.

           

          Is there an actual thread present to ask questions based on the materials presented in the 6part tutorials?

           

          I thought David's articles had a space below it to make comments and/or ask questions but I have not been spending time on DW forums recently because I have noticed that most answers here have duplicates or triplicates for most questions stating more or less the same thing so there isn't anything new here.

           

          I think I have covered almost everything asked in your question.

           

          Hope this help.

          • 2. Re: a basic questions on file paths
            bregent CommunityMVP

            is. <link href="./styles/main.css" the same as

                <link href="styles/main.css" ?

             

            >No it is not the same.  The first goes to the root folder

            >and looks for styles folder and then main.css file

             

            Tax, I think you did not see the dot before his first example.

             

            Here's how these work

             

            A single dot refers to the current directory

            A double dot referes to the parent directory

            A slash refers to the root.

             

            styles/main.css  - use the styles folder at the current level

            /styles/main.css - use the styles folder at the root level

            ./styles/main.css - use the styles folder at the current level

            ../styles/main.css - use the styles folder at the parent level

            ../../../styles/main.css - use the styles folder two levels up from the current level.

             

            http://www.webreference.com/html/tutorial2/3.html

            • 3. Re: a basic questions on file paths
              Rick Gerard CommunityMVP

              the dots before the backslash tell the browser to look back one level in the folder hierarchy.

               

              If your file structure looked like this:

               

              Root

                   CSS

                   Images

                        big images

                   adminPages

                        userPages

                             userpage.html

               

              test.html

               

               

               

              then a link to a file in the big images folder from the test.html page would simply be <img src="Images/big images/myImage.jpg>

               

              But to find the same image from the userpage.html document you would use <img src="../../images/myImage.jpg

               

              one dot

              ./someFolder/someFile.jpg

              is not valid markup and should not be used.

               

              a single backslash

              /someFolder/someFile.jpg creates a site relative to root link. It means start at the site root and go from there.

               

              Did you follow that? If you use the browse feature when you're writing code or you use the properties or insert features then Dreamweaver will always create the right path for you.

               

              http://www.mediacollege.com/internet/html/hyperlinks.html For more details.

              • 4. Re: a basic questions on file paths
                MurraySummers CommunityMVP

                @Rick - One dot is valid markup. It just means the current folder level as has already been pointed out.

                • 5. Re: a basic questions on file paths
                  Rick Gerard CommunityMVP

                  Thanks Murray,

                   

                  I don't have any reference to one dot in my HTML documentation. I'd never seen it before in any markup.

                  • 6. Re: a basic questions on file paths
                    MurraySummers CommunityMVP

                    It's not really HTML, it's basic file pathing. It was that way in <shudder>DOS</shudder>, and still is. It was that way in unix and still is. Not sure of a scenario where I could demonstrate how useful it is, though.

                    • 7. Re: a basic questions on file paths
                      bregent CommunityMVP

                      >Not sure of a scenario where I could

                      >demonstrate how useful it is, though.

                       

                      At the OS level, it's used to  explicitly reference the file in the current directory, and not another file of the same name in the file path.

                      • 8. Re: a basic questions on file paths
                        MurraySummers CommunityMVP

                        You mean at some intermediate stop along the way? If not, then how could there be two files with the same name at the same location?

                        • 9. Re: a basic questions on file paths
                          bregent CommunityMVP

                          Murray, what I should have said is 'a file of the same name in the file search path'. In DOS, when executing a file the current directory is always searched first, then the %PATH% is scanned. In most (all?) Unix shells, the current directory is not searched. So if you try to execute a file in the current directory, and that directory is not in the $PATH, you will get a 'command not found' error unless you preceed the filename with a "./"

                          • 10. Re: a basic questions on file paths
                            MurraySummers CommunityMVP

                            Gotcha. Yes, I now recall that from my DOS days. Thanks for the reminder!

                            • 11. Re: a basic questions on file paths
                              westwm Community Member

                              hi everyone thanks for the input!

                               

                              so

                               

                              ./styles/main.css is the same as styles/main.css

                               

                              is the latter considered THE way to write file paths for websites? I too was coming from a DOS and unix background and kind of like using "." to indicate absolute file paths but i couldnt remember exactly how they work (those were many university years ago)

                               

                              so something like

                               

                              <li><a href="./page1.html">Page1</a></li> is basically the same as

                              <li><a href="page1.html">Page1</a></li>

                               

                              again the latter is considered best and used by everyone as it results in shorter file paths?

                               

                              thanks again guys

                              • 12. Re: a basic questions on file paths
                                MurraySummers CommunityMVP

                                Your answers are no, yes and yes. And for what it's worth, "./page.html" is not considered an absolute link. There are four link types you need to keep up with in web development (at least using DW) -

                                 

                                absolute (http://www.example.com/whatever.html)

                                root relative (/folder/whatever.html)

                                document relative (../folder/whatever.html)

                                file (file:///...)

                                 

                                The latter is a broken link and will not work on the web. DW puts these kinds of links in your code when the linked file is OUTSIDE the root folder of the current site.

                                • 13. Re: a basic questions on file paths
                                  kutukde123 Community Member

                                  Thank you i'm used to my web site. And great still really cool one template.

                                   

                                  Look.

                                   

                                  {link removed by moderator}