1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

What's the "base" element's purpose ??

Discussion in 'HTML & Website Design' started by tayiper, Jul 27, 2006.

  1. #1
    It's used in the document's header (i.e. inside the "head" tags, and before the "body" tag), see for instance the http://www.sysinternals.com site, while the syntax of the element is the following:

    <base href="http://www.sysinternals.com/" />
    Code (markup):

    thanks in advance, tayiper
     
    tayiper, Jul 27, 2006 IP
  2. AdamSee

    AdamSee Well-Known Member

    Messages:
    422
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    135
    #2
    This module declares the base element type and its attributes,
    used to define a base URI against which relative URIs in the
    document will be resolved.

    Note that this module also redeclares the content model for
    the head element to include the base element.

    and

    http://webdesign.about.com/od/htmltags/p/bltags_base.htm
     
    AdamSee, Jul 27, 2006 IP
  3. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #3
    OK, thanks much for the reply ...


    tayiper
     
    tayiper, Jul 27, 2006 IP
  4. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #4
    Sorry, but I've realized that I am not completely sure what do you mean by that. Could you please explain it a bit more !!


    1. Also, I have few other questions too. If I use the following "base" code for my "Volja" site-variant:

    <base href="http://users.volja.net/tayiper/" />
    Code (markup):
    and as you can see, on the "index" page: index.html there is this kind of a list of links (I use "relative linking", of course):

    <a href="/tayiper/intro.html">intro</a> -- <a href="/tayiper/rules.html">rules</a> -- <a href="/tayiper/principles.html">principles</a> -- <a href="/tayiper/tweaks.html">tweaks</a> ...
    Code (markup):
    ... so if I would use that code, would the links link correctly to the respective pages, or would they link incorrectly to http://users.volja.net/tayiper/tayiper ?? Should I then rather put the code below instead, so that I would not need to modify the code on all the pages ?? The "base" code in question is the following:

    <base href="http://users.volja.net/" />
    Code (markup):

    2. Further, what about if I use the following code on all the "50webs" site-variant's pages:

    <base href="http://tadej-ivan.50webs.com/" />
    Code (markup):
    I am particularly interested for the list of links on the "intro" page: intro.html (which is located in the root directory), which is similar to, but a bit different than the one above, i.e. as you can see, compare to the above example, I do not use the additional slash char "/" to refer to the root of the site/domain-name, since this site is not hosted under a sub-directory and so this is not necessary:

    <ul><li><strong>intro</strong></li><li><a href="rules.html">rules</a></li> ... <li><a href="other/config.html">config</a></li><li><a href="other/terms.html">terms</a></li><li><a href="other/projects.html">projects</a></li><li>-- <a href="other/certs.html">certs</a></li><li><a href="other/diverse.html">diverse</a></li><li><a href="other/specs.html">specs</a> ...
    Code (markup):
    ... would then using that "base" code link to these pages correctly anyway ??


    Note that I use it like that (i.e. the list of links) only on pages that are same as the "intro" page, located under the root directory. I know that if I would, for instance use the list of links above on a page that is itself located under the "other" directory, the links that link to "other" (for instance "a href="other/config.html"") would then incorrectly link to http://tadej-ivan.50webs.com/other/other/config.html ??


    P.S. -- I am also curious: is the usage of this particular element valid by XHTML-specifications ??


    thanks again, tayiper
     
    tayiper, Jul 27, 2006 IP
  5. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #5
    OK, I even made two sample pages: index-basetest1.html, index-basetest2.html, and I can see for the second one that it doesn't read the root.css stylesheet-file correctly ...


    The stylesheet-file is referred to like this:

    <link rel="stylesheet" type="text/css" href="root.css" title="style" />
    Code (markup):
    P.S. -- Any further into/experiences on this is/are greatly appreciated !!


    tayiper
     
    tayiper, Jul 27, 2006 IP
  6. AdamSee

    AdamSee Well-Known Member

    Messages:
    422
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    135
    #6
    Haha, I seem to remember something similar to this before Tayiper :p

    It's the first time I saw it today and just got the definition straight from the Doctype files and had a look on google because it looked quite interesting.

    It seems to say to all the links; "This is the root, start here - no matter where you are in the webpage"
     
    AdamSee, Jul 27, 2006 IP
  7. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #7
    Aha, that's what I thought; but that complicates things a bit ...


    P.S. -- Althought it is true, that I don't need to use (i.e. it's not necessary) the "base" element at all !!


    tayiper
     
    tayiper, Jul 28, 2006 IP
  8. Gordaen

    Gordaen Peon

    Messages:
    277
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Base is xhtml valid (it has to be closed though)

    If you did <base href="http://www.somereallycoolsite.com/neatdirectory/" /> in the header then ALL of the URL's in your page that are relative will start at that point. So... <img src="photo.png" alt="Silly example" /> will be looked for at http://www.somereallycoolsite.com/neatdirectory/photo.png even if you are in http://www.somereallycoolsite.com/neatdirectory/notascooldirectory/somewhere/.
     
    Gordaen, Jul 28, 2006 IP
    tayiper likes this.
  9. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #9
    Aha, so it's that it considers it a "current" directory rather than a "root" one, since I can still refer to the root directory with that additional slash; see the example in one of the posts above ...


    P.S. -- I think that I got it now. For instance, I see that one of the sample-documents above is "screwed" because, as mentioned, I refer to my "root.css" stylesheet-file lke this:

    <link rel="stylesheet" type="text/css" href="root.css" title="style" />
    Code (markup):
    Therefore, the browser looks for it in the root directory. So in this particular case, I should do the "base" element like this (since the document itself is located under the "sample" directory):

    <base href="http://tadej-ivan.50webs.com/sample/" />
    Code (markup):
    Of course, the other possiblity would be one of the following ones (it doesn't matter for that slash, really); if I would refer to the "root.css" stylesheet-file as in the orginal example, i.e. without the "sample/" part:

    <link rel="stylesheet" type="text/css" href="sample/root.css" title="style" />
    Code (markup):
    <link rel="stylesheet" type="text/css" href="/sample/root.css" title="style" />
    Code (markup):
    tayiper
     
    tayiper, Jul 28, 2006 IP
  10. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #10
    Oh, and one more fundamental question: where in the header is it best to put it ?? After the "title" element and before the "meta" ones, or after the "meta" ones etc. ?? (I surely know that I need to put it before first occurance of relative linking though)


    tayiper
     
    tayiper, Jul 28, 2006 IP
  11. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #11
    ***bump***
     
    tayiper, Jul 29, 2006 IP
  12. AdamSee

    AdamSee Well-Known Member

    Messages:
    422
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    135
    #12
    Base - I'd put it right near the top as possible, if you need it that is.
     
    AdamSee, Jul 29, 2006 IP