<base /> tag

M

Mark Simon

I like to use the <base> tag in, say, the contents frame of a frameset.
The idea is that the target attribute will direct all of the links into
another frame.

The base tag technically has a required href attribute, which should be
an absolute reference. I have no use for this href attribute, and it
tends to cause the relative links on the page not to work properly.
However, without it, the page won't validate properly.

Is there a valid href value I can use which will allow other relative
links on the page to work?

Below is an example:

<html>
<head>
...
<base href="?" target="mainFrame" />
</head>
<body>
...
<a href="otherpage.html">Other Page</a>
...
</body>
</html>

The only "correct" solutions I can think of are either to simply put
targets into all of my links, or to use absolute addresses ... ?

Thanks,

Mark
 
R

Rob McAninch

Mark Simon>:
The base tag technically has a required href attribute, which should be
an absolute reference. I have no use for this href attribute, and it
tends to cause the relative links on the page not to work properly.
However, without it, the page won't validate properly.

Indeed, could you give a URL?

My site in the signature would have <base href="http://rock13.com/">
with all the relative URLs starting like "webhelp/perl/".

It sounds like your base href was formatted incorrectly.
 
M

Mark Simon

Rob said:
Mark Simon>:



Indeed, could you give a URL?

My site in the signature would have <base href="http://rock13.com/">
with all the relative URLs starting like "webhelp/perl/".

It sounds like your base href was formatted incorrectly.
Understood. However, if your relative URLs were all in the same
directory as the current page, and you were to move your pages to
another host or another directory, you would have to modify your <base
/> tag, which would be a shame, and make the whole page less relative.

Thanks,

Mark
 
J

Jukka K. Korpela

Mark Simon said:
I like to use the <base> tag in, say, the contents frame of a frameset.

Just don't use frames. Problem solved. Now, assuming you still wish to create
problems by using frames,...
The idea is that the target attribute will direct all of the links into
another frame.

Then you would need to use a Transitional DTD, since Strict DTDs disallow the
target attribute.
The base tag technically has a required href attribute,

Only in Strict DTDs, which are out of the question anyway when you use the
target attribute.

I hadn't noticed that Strict DTDs make the href attribute required, but
that's actually quite logical: since the target attribute is disallowed, the
only possible purpose for the <base> tag would be to set the base address for
URLs. Thus, if you are using a Strict DTD and you use a <base> element
without a href attribute, you have made some error in your thinking or
coding, so it's useful to regard this as a syntax error.
However, without it, the page won't validate properly.

Posting the URL would, as so often, made it possible to others to help you
better. Yet, it seems pretty obvious that the analysis above is correct.
Is there a valid href value I can use which will allow other relative
links on the page to work?

No. The <base href="..."> construct by definition sets the base address for
_all_ relative URLs (not just links).

P.S. There's no point in using XHTML instead of HTML 4.01 on the web; it just
causes confusion.
The only "correct" solutions I can think of are either to simply put
targets into all of my links, or to use absolute addresses ... ?

The correct solution is to stop using frames.
 
P

Peterken

Mark Simon said:
I like to use the <base> tag in, say, the contents frame of a frameset. The
idea is that the target attribute will direct all of the links into another
frame.

The base tag technically has a required href attribute, which should be an
absolute reference. I have no use for this href attribute, and it tends to
cause the relative links on the page not to work properly. However,
without it, the page won't validate properly.

Is there a valid href value I can use which will allow other relative
links on the page to work?

Below is an example:

<html>
<head>
...
<base href="?" target="mainFrame" />
</head>
<body>
...
<a href="otherpage.html">Other Page</a>
...
</body>
</html>

The only "correct" solutions I can think of are either to simply put
targets into all of my links, or to use absolute addresses ... ?

Thanks,

Mark

hm, tried <base href="./" target="mainFrame"/> for that matter?
using "dot slash" sets current dir as base.
not sure if it's correct, but it would my first attempt.....
 
J

Jukka K. Korpela

Peterken said:
hm, tried <base href="./" target="mainFrame"/> for that matter?
using "dot slash" sets current dir as base.
not sure if it's correct, but it would my first attempt.....

Why should anyone "try" it, when the specifications clearly say that the
value must be an absolute URL (as the text you quoted said*)?

*) Comprehensive quoting is a fairly sure sign of lack of comprehensive
reading.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,811
Latest member
SaulFernan

Latest Threads

Top