Archive

Posts Tagged ‘web developing’

Base-tag-href

March 2nd, 2008 2 comments

 I was pretty confused about the <base /> tag in HTML. If your base tag look like this:

<base href="http://somedomain.com" />

and your link looks like this:

<a href="page1.html">page1</a>

your link would point to http://somedomain.com/page1.html

If your base tag looked like:

 <base href="http://somedomain.com/folder" /> *whithout a trailing slash*

your link would still point to http://somedomain.com/page1.html

If you add the slash -> <base href="http://somedomain.com/folder/" />

your link would now point to http://somedomain.com/folder/page1.html

Now, as I can see it. If you add a "/" in front of your link 

<a href="/page1.html">page1</a>

and your base still looks like

<base href="http://somedomain.com/folder/" />

The link would point to http://somedomain.com/page1.html ignoring the /folder/

 This page http://www.drostdesigns.com/base-href-tag/ tells people always to add a "/" in front of all the link, but then you are not able to put subdirectories in your base tag.

This page http://www.cs.tut.fi/~jkorpela/HTML3.2/5.7.html makes an example without the "/" in the link.

It makes more sense to me, not to add the "/" in front of all the links, making it easy to change the base href to whatever you want, but maybe I have missed something.

 

Categories: web developing Tags: ,