Does <A HREF hyperlink require "http://..."?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yeah

    Does <A HREF hyperlink require "http://..."?

    Is it absolutely necessary to include "http://" in an A HREF hyperlink?
    Would it be wise to remove this from one's Links page, just to save code?


  • Barbara de Zoete

    #2
    Re: Does &lt;A HREF hyperlink require &quot;http://...&quot;?

    On Wed, 04 Jan 2006 18:46:49 +0100, Yeah <yeah@positive. net> wrote:
    [color=blue]
    > Is it absolutely necessary to include "http://" in an A HREF hyperlink?[/color]

    Only for http addresses:

    <URL:http://www.w3.org/Addressing/URL/5_BNF.html>
    [color=blue]
    > Would it be wise to remove this from one's Links page, just to save code?[/color]

    If you remove it, it is no longer a URL. That doesn't sound 'wise' to me.


    --
    ,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
    | weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
    | webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
    |zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
    `-------------------------------------------------- --<--@ ------------'

    Comment

    • Darin McGrew

      #3
      Re: Does &lt;A HREF hyperlink require &quot;http://...&quot;?

      Yeah <yeah@positive. net> wrote:[color=blue]
      > Is it absolutely necessary to include "http://" in an A HREF hyperlink?[/color]

      Yes.
      [color=blue]
      > Would it be wise to remove this from one's Links page, just to save code?[/color]

      As an example, the link page at http://www.htmlhelp.com/links/ could use
      href="http://www.example.com/" and the link would refer to


      But if the link page at http://www.htmlhelp.com/links/ used
      href="www.examp le.com/" instead, then the link would refer to
      http://www.htmlhelp.com/links/www.example.com/ which is not the same thing
      at all.

      See also http://www.htmlhelp.com/faq/html/bas...l#relative-url
      --
      Darin McGrew, mcgrew@stanford alumni.org, http://www.rahul.net/mcgrew/
      Web Design Group, darin@htmlhelp. com, http://www.HTMLHelp.com/

      "Shin: a device for finding furniture in the dark." - Steven Wright

      Comment

      • David Dorward

        #4
        Re: Does &lt;A HREF hyperlink require &quot;http://...&quot;?

        Yeah wrote:
        [color=blue]
        > Is it absolutely necessary to include "http://" in an A HREF hyperlink?
        > Would it be wise to remove this from one's Links page, just to save code?[/color]

        If you don't include the protocol, then it is a relative link, so if you
        have a page at http://example.com/foo/index.html and links with
        href="www.examp le.net" and href="http://www.example.org " the links would be
        to "http://www.example.com/foo/www.example.net " and
        "http://www.example.org ".

        --
        David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
        Home is where the ~/.bashrc is

        Comment

        • Harlan Messinger

          #5
          Re: Does &lt;A HREF hyperlink require &quot;http://...&quot;?

          Yeah wrote:[color=blue]
          > Is it absolutely necessary to include "http://" in an A HREF hyperlink?
          > Would it be wise to remove this from one's Links page, just to save code?
          >[/color]

          If you had

          href="www.examp le.com/mypage.html"

          on the page located at http://www.example.com/otherpage.html, following
          the usual rules for interpreting relative URLs, the browser would
          interpret it as



          Comment

          • lunaticfringe

            #6
            Re: Does &lt;A HREF hyperlink require &quot;http://...&quot;?


            Yeah Wrote:[color=blue]
            > Is it absolutely necessary to include "http://" in an A HREF hyperlink?
            > Would it be wise to remove this from one's Links page, just to save
            > code?[/color]

            It depends on where the link is going. If you are on the same URL then
            you don't need it.

            example
            <a href="new.html" > this is within the same folder on the same URL
            <a href="images/picture.jpg"> this is within the same URL in a
            subfolder
            <a href="../file.html"> this is within the same URL but in the folder
            above

            If the link is going to an outside URL or you have trouble with being
            within a subfolder and accessing outside of it then yes you may need to
            make an absolute URL for it to follow.

            Saving code really depends on what is on the page (amount of links and
            size) and SEO.


            --
            lunaticfringe
            ------------------------------------------------------------------------
            lunaticfringe's Profile: http://2006.html.com/forums/member.php?userid=1049
            View this thread: http://2006.html.com/forums/showthread.php?t=43517

            1


            ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
            http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
            ----= East and West-Coast Server Farms - Total Privacy via Encryption =----

            Comment

            • Bruce Lewis

              #7
              Re: Does &lt;A HREF hyperlink require &quot;http://...&quot;?

              Darin McGrew <mcgrew@stanfor dalumni.org> writes:
              [color=blue]
              > See also http://www.htmlhelp.com/faq/html/bas...l#relative-url[/color]

              I want to amplify Darin's reference, because this page includes the
              important example href="./" that is too often neglected. If you have a
              default file, using href="./" in place of href="index.htm l" and such
              will mean consistent URLs instead of http://example.com/ and
              http://example.com/index.html having the same content.

              --

              http://ourdoings.com/ Easily organize and disseminate news and
              photos for your family or group.

              Comment

              • Stan Brown

                #8
                Re: Does &lt;A HREF hyperlink require &quot;http://...&quot;?

                Wed, 4 Jan 2006 11:46:49 -0600 from Yeah <yeah@positive. net>:[color=blue]
                > Is it absolutely necessary to include "http://" in an A HREF hyperlink?[/color]

                No, of course not -- sometimes it's wrong to include that.
                [color=blue]
                > Would it be wise to remove this from one's Links page, just to save code?[/color]

                No, that would be stupid.


                But you're not asking the right question. The _right_ question is,
                what's the path from the current page to the linked page? If both are
                on the same server, you want a relative link; if not, you want an
                absolute link. The absolute link always needs the protocol, news: or
                http:// or whatever. The relative link never has the protocol or
                server and, depending on details, will also omit some of the leading
                "directory" names.

                --
                Stan Brown, Oak Road Systems, Tompkins County, New York, USA

                HTML 4.01 spec: http://www.w3.org/TR/html401/
                validator: http://validator.w3.org/
                CSS 2.1 spec: http://www.w3.org/TR/CSS21/
                validator: http://jigsaw.w3.org/css-validator/
                Why We Won't Help You:

                Comment

                • Eric Lindsay

                  #9
                  Re: Does &lt;A HREF hyperlink require &quot;http://...&quot;?

                  In article <nm91wznkcln.fs f@grumpy-fuzzball.mit.ed u>,
                  Bruce Lewis <brlspam@yahoo. com> wrote:
                  [color=blue]
                  > Darin McGrew <mcgrew@stanfor dalumni.org> writes:
                  >[color=green]
                  > > See also http://www.htmlhelp.com/faq/html/bas...l#relative-url[/color]
                  >
                  > I want to amplify Darin's reference, because this page includes the
                  > important example href="./" that is too often neglected. If you have a
                  > default file, using href="./" in place of href="index.htm l" and such
                  > will mean consistent URLs instead of http://example.com/ and
                  > http://example.com/index.html having the same content.[/color]

                  I like that. So the idea is you could change all your references now to
                  an older style default file like href="index.htm " to href="./" Then
                  where you finally get around to making your default file "index.html "
                  (or "default.ht ml" or whatever a newer default file name is) you don't
                  need to make a change to any of your HTML default page references?

                  Are there any disadvantages? Extra lookup time vs having the path
                  including the actual file name used?

                  --
                  Eric Lindsay's web sites, featuring Airlie Beach diving, sailing tourist area, Psion Epoc computers, Gegenschein Science fiction fanzine.

                  Comment

                  • David Ross

                    #10
                    Re: Does &lt;A HREF hyperlink require &quot;http://...&quot;?

                    Yeah wrote:[color=blue]
                    >
                    > Is it absolutely necessary to include "http://" in an A HREF hyperlink?
                    > Would it be wise to remove this from one's Links page, just to save code?[/color]

                    In addition to all the other answers about relative links, you
                    should recognize that not all links use the hyper-text transfer
                    protocol (HTTP). For example, a link to send E-mail to the
                    anti-spam address I used for this message would be
                    <a href="mail:nobo dy@nowhere.not" >Mail to me</a>

                    And a link to reach this newsgroup through your default news server
                    would be
                    <a href="news:comp .infosystems.ww w.authoring.htm l">Authoring
                    HTML</a>
                    Specifying a particular news server would be
                    <a
                    href="news://news.vcnet.com/comp.infosystem s.www.authoring .html">Authorin g
                    HTML</a>

                    Generally, when I refer to a page in my own Web site from another
                    page in the same site, I user relative links. This facilitates
                    both testing and rehosting.

                    For testing, links relative to my home page allow me to recreate my
                    Web site in a local directory on my PC. This means that I can
                    navigate through my site without even connecting to the Internet.
                    Thus, I can check the appearance of a page and the integrity of
                    links without having to upload the pages to a Web server.

                    If I want to rehost my Web site, none of my links require
                    changing. I only have to change text that cites the domain. Yes,
                    I now have a personal domain, which means that rehosting merely
                    requires pointing the domain to the new server and uploading the
                    files, even if my links used complete URLs. However, if I were to
                    change the name of my domain, relative links mean that I would not
                    have to change them.

                    --

                    David E. Ross
                    <http://www.rossde.com/>

                    Concerned about someone (e.g., Pres. Bush) snooping
                    into your E-mail? Use PGP.
                    See my <http://www.rossde.com/PGP/>

                    Comment

                    • Mark Parnell

                      #11
                      Re: Does &lt;A HREF hyperlink require &quot;http://...&quot;?

                      Deciding to do something for the good of humanity, David Ross
                      <nobody@nowhere .not> spouted in comp.infosystem s.www.authoring.html:
                      [color=blue]
                      > <a href="mail:nobo dy@nowhere.not" >Mail to me</a>[/color]

                      I think you mean mailto: not mail:

                      With all the standard caveats (i.e. it may not work) of course.

                      --
                      Mark Parnell
                      =============== =============== =============== ========
                      Att. Google Groups users - this is your last warning:

                      Comment

                      • Michael Winter

                        #12
                        Re: Does &lt;A HREF hyperlink require &quot;http://...&quot;?

                        On 04/01/2006 17:46, Yeah wrote:
                        [color=blue]
                        > Is it absolutely necessary to include "http://" in an A HREF hyperlink?[/color]

                        It depends what the destination is and the current base URI that any
                        relative URI might be resolved against.

                        If the link points to a site that uses a different scheme (https, ftp,
                        etc.) then an absolute URI is necessary. If the scheme is the same, then
                        you could use a network path reference. It's essentially an absolute URI
                        with the scheme removed.

                        From a document at



                        the relative URI

                        //www.google.com/

                        would resolve to


                        [color=blue]
                        > Would it be wise to remove this from one's Links page, just to save code?[/color]

                        Not really. It's only a few characters (five, in this case), so unless
                        there are thousands of such links, there's little return. If there were
                        thousands of links, time would be better spent recategorising them into
                        /much/ smaller lists.

                        Mike

                        --
                        Michael Winter
                        Prefix subject with [News] before replying by e-mail.

                        Comment

                        • Eric B. Bednarz

                          #13
                          Re: Does &lt;A HREF hyperlink require &quot;http://...&quot;?

                          David Ross <nobody@nowhere .not> writes:
                          [color=blue]
                          > For example, a link to send E-mail to the
                          > anti-spam address I used for this message would be
                          > <a href="mail:nobo dy@nowhere.not" >Mail to me</a>[/color]

                          <http://en.wikipedia.or g/wiki/.invalid>

                          Sigh.

                          FWIW, my from address is valid and auto-trashed, my reply-to address is
                          a free webmail service that employs its own spamfilters and beyond any
                          messages > 20KiB get auto-trashed as well. In 2005 I found exactly 0
                          (zero) occurances of spam in that Inbox.

                          My primary addresses are mostly harvested on Windows machines of social
                          and business relations, not on the Web or even Usenet, so I see little
                          reason to harvest unregistered TLDs myself to play silly games. Be so
                          kind to think about that as well.
                          [color=blue]
                          > Specifying a particular news server would be[/color]

                          Undocumented?
                          [color=blue]
                          > For testing, links relative to my home page allow me to recreate my
                          > Web site in a local directory on my PC. This means that I can
                          > navigate through my site without even connecting to the Internet.[/color]

                          Setting up a local web server shouldn't take more than 15 minutes for a
                          first time attempt even on win98. Besides the benefits of a real test
                          environment, you cannot seriously want to include the DirectoryIndex
                          file names in your relative URI references?

                          Comment

                          • Rob McAninch

                            #14
                            Re: Does &lt;A HREF hyperlink require &quot;http://...&quot;?

                            Eric Lindsay>:[color=blue]
                            > In article <nm91wznkcln.fs f@grumpy-fuzzball.mit.ed u>,
                            > Bruce Lewis <brlspam@yahoo. com> wrote:[color=green]
                            >>Darin McGrew <mcgrew@stanfor dalumni.org> writes:
                            >>
                            >>[color=darkred]
                            >>>See also http://www.htmlhelp.com/faq/html/bas...l#relative-url[/color]
                            >>
                            >>I want to amplify Darin's reference, because this page includes the
                            >>important example href="./" that is too often neglected.[/color][/color]
                            [color=blue]
                            >
                            > I like that. So the idea is you could change all your references now to
                            > an older style default file like href="index.htm " to href="./" [...][/color]
                            [color=blue]
                            > Are there any disadvantages? Extra lookup time vs having the path
                            > including the actual file name used?[/color]

                            Technically there would be a brief lookup time (probably in the
                            millisecond range) for the server to consult the configuration and
                            then look for a default file to serve. As opposed to serving a
                            directly referenced file (which still requires some configuration
                            decisions from the server).

                            Nothing to worry about. Though be sure to configure the server's
                            search order for the correct default file.

                            --
                            Rob McAninch

                            Comment

                            • Bruce Lewis

                              #15
                              Re: Does &lt;A HREF hyperlink require &quot;http://...&quot;?

                              Rob McAninch <rob_13@excite. com> writes:
                              [color=blue]
                              > Technically there would be a brief lookup time (probably in the
                              > millisecond range) for the server to consult the configuration and
                              > then look for a default file to serve. As opposed to serving a
                              > directly referenced file (which still requires some configuration
                              > decisions from the server).[/color]

                              I think this is a pessimistic view of how it would work. Only the very
                              worst web server implementations on very old hardware would require a
                              whole millisecond to do it.

                              More likely enough information would be cached in memory to make the
                              delay immeasurable.

                              Comment

                              Working...