SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb What is the purpose of the Base Element

    I can't seem to wrap my head around what the <base> element really does, and what its purpose is. Can anyone explain in laymans terms "what" and "why". I am new to webdesign and just trying to understand all the elements. I would appreciate any help. Thanks

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,598
    Mentioned
    411 Post(s)
    Tagged
    6 Thread(s)
    Hi wwwebster. Welcome to SitePoint.

    The base element isn't used much, and is rarely needed. Here is some more info on it:

    base (HTML element)

    Basically, it can make writing out URLs a bit simpler. If you, say, have lots of images on a page, instead of doing something like this:

    Code:
    <body>
    <img src="../../images/image1.gif" alt="">
    <img src="../../images/image2.gif" alt="">
    <img src="../../images/image3.gif" alt="">
    </body>
    you could instead do this:

    Code:
    <head>
    <base href="http://mysite.com/images/">
    </head>
    
    <body>
    <img src="image1.gif" alt="">
    <img src="image2.gif" alt="">
    <img src="image3.gif" alt="">
    </body>
    But really, I prefer to do something like this without the base element:

    Code:
    <body>
    <img src="/images/image1.gif" alt="">
    <img src="/images/image2.gif" alt="">
    <img src="/images/image3.gif" alt="">
    </body>
    The / at the start of the URL is a root-relative URL, and is much more straightforward. It won't work in testing on you own computer, though, unless you use a virtual server environment, such as is offered by MAMP (for Mac) ow XAMPP (for PC).

  3. #3
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help. It makes perfect sense to me now. Thanks for the info on the VSE. I am really starting to love this stuff.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •