id versus name attributes in XHTML

They have: 222 posts

Joined: Sep 1999

Let's say I've got a page ("A") that has an inline frame ("B") in it. There are links on A that are supposed to open up inside B. The XHTML spec says to use the id attribute instead of name to name the iframe, right?

But when I put id="content" inside the iframe tag and then put target="content" inside the links the page opens up in a new window, as if there was nothing named "content".

If I use name="content" then everything works fine, but that's not XHTML compliant.

If I try id="content" and then put target="#content" inside the links IE freezes (v6 on XP w/ 512M RAM).

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

Since ID doesn't work for older browsers, you'll have to double up to get it to work, but the problem is validation.

http://www.w3.org/TR/xhtml1/#guidelines

I believe that target itself is deprecated, and you can use client side scripting to control the linking.

They have: 222 posts

Joined: Sep 1999

So, I should use iframe id="blah" name="blah" and a href="wherever.html" target="blah". But won't that only be working because of the name attribute? Because if it was only id in there it would just open it in a new window.

Are there any rules I have to follow when when choosing the value of id/name?

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

You know, I'm not sure. I haven't tried to get xhtml working with a frameset.

There must be some references somewhere, I'll try to find out and report back.

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

http://www.webreference.com/xml/column6/4.html

#7 seems to be the same advice. I'll keep looking, though.

The naming convention would be the same, must start with A-Z or a-z, but can be otherwise alphanumeric, no special characters.

They have: 222 posts

Joined: Sep 1999

Cool, thanks

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.