My Secret Life as a Spaghetti Coder
home | about | contact | privacy statement
While I know I've still got tons to learn (just look at the nice table structure on this site, seeing as CSS naked day was yesterday), I've still been doing this stuff for six years or so now, and thanks to a comment from Justin Mclean on his blog, I've just learned something comepletely new to me: the base tag.

I feel like a complete newbie (or n00b or newb, or however your preferred spelling goes). Basically, any relative links will be preceded by that listed in the href attribute. It appears to need to be a full http:// and so forth, but that's easily made dynamic (in CF - you'll have to consult your docs for other languages) with cgi.server_name or cgi.http_host (as Justin pointed out. Thanks Justin!)

So, now my question to you all: who else didn't know about this? Don't be shy - If I'm not too embarassed to share my ignorance, neither should you be!

Hey! Why don't you make your life easier and subscribe to the full post or short blurb RSS feed? I'm so confident you'll love my smelly pasta plate wisdom that I'm offering a no-strings-attached, lifetime money back guarantee!

Leave a comment

Oh, I forgot to put an example. It's use should look like:

<base href=""/>

and then any relative links in the page will have than prepended to them.

Posted by Sam on Apr 06, 2007 at 08:03 AM UTC - 5 hrs

Just a note about that... we used to use Base-Target in a frame-set (where all the links in one frame [nav] would load into another frame via default target). Worked great until IE7. Apparently the Base Target stopped working in IE7 (at least for Frame-based-targets).

I think that might be a XHTML standars or something.

Posted by Ben Nadel on Apr 06, 2007 at 09:18 AM UTC - 5 hrs

It's funny I didn't know about it till I started using <a href="">SESconveter</a>

And then I had the same "Wow never knew that was there" moment.

Posted by jeff on Apr 06, 2007 at 10:10 AM UTC - 5 hrs

That link for SES converter is at

Posted by Sam on Apr 06, 2007 at 10:12 AM UTC - 5 hrs

Yup, sesConverter brought that little tag to light for a lot of people.

I actually still use it, too. Not sure how long that fusium page will remain up.

Posted by erikv on Apr 06, 2007 at 11:33 AM UTC - 5 hrs

I learned exactly what the base tag did a few years ago when debugging an application that was scraping Yahoo!'s homepage and embedding it within the application's rendered output (this was just a test scenario, no Yahoo! content was harmed in any way).

Yahoo! included (and maybe still includes) a base tag so any relative links that belonged to my application and appeared after the scraped content got re-routed. Oops. Hello, base tag. Nice to meet you.

Posted by Rob Wilkerson on Apr 06, 2007 at 11:53 AM UTC - 5 hrs

That's a great story Rob!

Posted by Sam on Apr 06, 2007 at 11:59 AM UTC - 5 hrs

I was vaguely aware of the tag and, in theory at least, knew what it would do, but had never used it myself and was *totally* unprepared for its impact on what I was trying to do. Took me *hours* to figure out WTF was going on.

Posted by Rob Wilkerson on Apr 06, 2007 at 12:02 PM UTC - 5 hrs

I've known about the base tag for as long as I can remember. It also works well for certain situations when you're trying to embed like a java applet or swf from a different domain.

Posted by Brad on Apr 06, 2007 at 12:49 PM UTC - 5 hrs

>That link for SES converter is at

Neither of the above links work, does anyone have alternate links for the ses converter, please?

Posted by Seamus Campbell on May 26, 2007 at 06:55 AM UTC - 5 hrs

Seamus, they both seem to work fine for me. Try going to it directly at


Posted by Sam on May 26, 2007 at 08:10 AM UTC - 5 hrs

Thanks - got it now

Posted by Seamus Campbell on May 26, 2007 at 10:06 AM UTC - 5 hrs

It's good to learn new tags that are out there and what they do, but I always strongly discourage the use of the <base> tag. It's nice if you're staging a site or moving from one server to another, but it can cause all kinds of unintended consequences down the road, especially if you end up doing anything serious with Flash or AJAX. It seems like all browsers handle the base tag differently, and relying on the <base> tag can cause a world of unintended frustration down the road.

Posted by andy on Jun 12, 2007 at 12:13 PM UTC - 5 hrs

Thanks for the heads up andy, it is definitely a good consideration. I still haven't used the base tag, but I think its because I got too used to doing it dynamically when I needed to.

Posted by Sam on Jun 12, 2007 at 01:36 PM UTC - 5 hrs

<a href="">wholesale</a>, <a href="">wholesale handbags</a>,<a href=""> wholesale sungalsses</a>,<a href="">wholesale jewelry</a>,<a href="">wholesale cosmetics</a>, <a href="">wholesale shoes</a>,<a href="">wholesale caps</a><br />
<a href=""></a></p>

Posted by wholesale Handbags on Oct 31, 2010 at 03:25 AM UTC - 5 hrs

Leave a comment

Leave this field empty
Your Name
Email (not displayed, more info?)


Subcribe to this comment thread
Remember my details

Picture of me

.NET (19)
AI/Machine Learning (14)
Answers To 100 Interview Questions (10)
Bioinformatics (2)
Business (1)
C and Cplusplus (6)
cfrails (22)
ColdFusion (78)
Customer Relations (15)
Databases (3)
DRY (18)
DSLs (11)
Future Tech (5)
Games (5)
Groovy/Grails (8)
Hardware (1)
IDEs (9)
Java (38)
JavaScript (4)
Linux (2)
Lisp (1)
Mac OS (4)
Management (15)
MediaServerX (1)
Miscellany (76)
OOAD (37)
Productivity (11)
Programming (168)
Programming Quotables (9)
Rails (31)
Ruby (67)
Save Your Job (58)
scriptaGulous (4)
Software Development Process (23)
TDD (41)
TDDing xorblog (6)
Tools (5)
Web Development (8)
Windows (1)
With (1)
YAGNI (10)

Agile Manifesto & Principles
Principles Of OOD
Ruby on Rails

RSS 2.0: Full Post | Short Blurb
Subscribe by email:

Delivered by FeedBurner