Forum Moderators: open

Message Too Old, No Replies

W3C HTML4.01 and base href problem

Seems advice is to have base href but W3C do not think so

         

Moncao

8:32 am on Sep 3, 2006 (gmt 0)

10+ Year Member



Hi

I have a site which is HTML4.01 compliant. I read about domain hijacking (I think that is the correct term) and the need to put a meta base href in your html. Problem is this makes my site non-compliant.

Any advice?

kaled

9:37 am on Sep 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The base tag is NOT a meta tag.

<head>
...
<base href="thispage.html" target="_top">
....
</head>

Adding the target="_top" attribute will ensure that if someone frames your site, the frames will be broken by the first user click.

Kaled.

hiddenboston

4:03 pm on Sep 8, 2006 (gmt 0)

10+ Year Member



But you can't use the TARGET attribute if you are using XHTML/HTML strict, can you?

LunaC

3:33 pm on Sep 9, 2006 (gmt 0)

10+ Year Member



Base hrefs don't have a target, that's the part that's making it invalid. Just add this into your head (with your domain name of course):

<base href="http://www.example.com/">

I use that and validate just fine. According to what I found on the W3C, it's advised to use the full URL for each page, ie.

<base href="http://www.example.com/page.html">
<base href="http://www.example.com/folder/page.html"> etc.

kaled

3:54 pm on Sep 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



But you can't use the TARGET attribute if you are using XHTML/HTML strict, can you?

The original question specified HTML 4.01 (without specifying loose or strict).

You can use the target attribute even in XHTML however it may stop validation. I've argued it many times before, but the absence of the target attribute from certain doctypes is just plain stupid. If you need it, use it, if you don't then don't.

Correct functionality is more important than validation.

Kaled.