Thread: The base tag

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Posts
    9
    Rep Power
    0

    Red face The base tag


    Hi,
    I have the below code,
    Code:
    <!DOCTYPE html>
    <html>
        <head>
    		<base href="www.google.com/">
        </head>
        <body>
            <p>Visit the <a href="archives.html">archives</a>.</p>
        </body>
    </html
    So the link is:
    file:///C:/Users/PC/Desktop/www.google.com/archives.html
    When add http in base tag
    Code:
    <base href="www.google.com/">
    To
    Code:
    		<base href="http://www.google.com/">
    the problem is solve and link is:
    http://www.google.com/archives.html
    Why?
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,997
    Rep Power
    9397
    Because "www.google.com" by itself is just a name like "archives.html". You need the //s at the very least for the browser to know that it's supposed to be a domain.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Posts
    9
    Rep Power
    0
    Thank you for your reply,
    But i don't understand it
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Yeah, that's the problem of modern browsers: They hide all the technical details, and in the end, people forget how an URL actually looks like.

    An absolute URL consists of a scheme, a domain and a path. A scheme is something like "http" or "https" and specifies the protocol to use. The domain in your case would be "google.com". And the path is "/".

    So the full URL is

    Code:
    https://google.com/
    If you leave out the scheme, you get a relative URL which points to a resource on the current site. So

    Code:
    www.google.com/
    actually means

    Code:
    current_scheme://current_comain/current_path/www.google.com/
    This is of course total nonsense.

    So you must specify the scheme. You can either explicitly write it down like above or use a scheme-relative URL as explained by requinix.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

IMN logo majestic logo threadwatch logo seochat tools logo