|
Posted by Yeah on January 4, 2006, 11:46 am
Please log in for more thread options
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?
|
|
Posted by lunaticfringe on January 4, 2006, 1:34 pm
Please log in for more thread options
Yeah Wrote:
> 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?
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 =----
|
|
Posted by Harlan Messinger on January 4, 2006, 1:57 pm
Please log in for more thread options
Yeah wrote:
> 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?
>
If you had
href="www.example.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
http://www.example.com/www.example.com/mypage.html
|
|
Posted by Stan Brown on January 4, 2006, 2:53 pm
Please log in for more thread options
> Is it absolutely necessary to include "http://" in an A HREF hyperlink?
No, of course not -- sometimes it's wrong to include that.
> Would it be wise to remove this from one's Links page, just to save code?
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
http://OakRoadSystems.com/ 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:
http://diveintomark.org/archives/2003/05/05/why_we_wont_help_you
|
|
Posted by David Ross on January 4, 2006, 3:20 pm
Please log in for more thread options
Yeah wrote:
>
> 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?
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
And a link to reach this newsgroup through your default news server
would be
<a href="news:comp.infosystems.www.authoring.html">Authoring
HTML</a>
Specifying a particular news server would be
<a
href="news://news.vcnet.com/comp.infosystems.www.authoring.html">Authoring
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/>
|
|