Click to See Complete Forum and Search --> : <a Target=?>


AWhiteC
04-20-2003, 08:46 AM
The TARGET attribute of the A element is not allowed in strtct HTML 4.01. What's the work-around for this if you want to nominate a frame for the document to appear in, but want to remain strict?

khalidali63
04-20-2003, 09:11 AM
I dare to disagree,
it is allowed,the only possibility is that you might have it in caps which is not conformant to w3c standards,
beginning html4.01 all element names and there attributes must be in lower case,and all attributes must be enclosed in qoutes,unless, you write your code in some kind of MS software,MS WYSIWYGs are notorious for their non-compiant code generation

:D

khalidali63
04-20-2003, 09:49 AM
Originally posted by Dave Clark
I use the latest version of FrontPage and it has options.....
Dave

You are probably right,however,as I have never used MS tools,"but" have seen microsoft generated code for years,and not one time have I seen a standard compliant piece( its quite possible that I saw only the bad code..:p ).
As far as target attribute is conern as of this moment I know for sure that its a valid attribute to be used in html, try validating a sample here

http://validator.w3.org/

AWhiteC
04-20-2003, 10:01 AM
Originally posted by khalidali63
... beginning html4.01 all element names and there attributes must be in lower case ...

I disagree! - sorry! I found, for example: '<A href="cih78">' in http://www.w3.org/TR/html4/struct/text.html#edef-P, which is part of the 4.01 specification.

khalidali63
04-20-2003, 10:28 AM
Originally posted by AWhiteC
I disagree! - sorry! I found, for example: '<A href="cih78">' in http://www.w3.org/TR/html4/struct/text.html#edef-P, which is part of the 4.01 specification.

Disagree as much as you want,I thought you posted here for help,on the contrary you wanted to disagree...thats fine,for the future though,I'd suggest before you disagree,try validating some html elements with caps at this link

http://validator.w3.org/

And then if I am wrong,I'll appologise

:D

AWhiteC
04-20-2003, 11:41 AM
I tried http://validator.w3.org/ and got:

Line 122, column 179: there is no attribute "TARGET".
target="_top">"

I only get this when the DOCTYPE is set "4.01 strict".

AWhiteC
04-20-2003, 11:44 AM
Incidentally, the markup I use is:

<A href="..." target="_top">...</A>

... just to show the case and quotes.

khalidali63
04-20-2003, 11:59 AM
can you please post your doctype code here?

AWhiteC
04-20-2003, 05:12 PM
Originally posted by khalidali63
can you please post your doctype code here?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

khalidali63
04-20-2003, 05:21 PM
thats the one I use too,but mostly I validate(or try to for sure) my code with
w3c validator the link I posted above,and I see no errors unless attribute or an element name is on caps,and I know this is true for over a year now..at least.I hope you understadn by now that..target attribute at this time is a valid html attribute for element anchor,the best policy would be to validate your docs agains w3c validator and try no to use caps at all,with attribute values in qoutes..

:D

nkaisare
04-20-2003, 10:21 PM
Khalid:
1. Caps elements and attributes are allowed in HTML, they are not allowed in XHTML. Valid examples
<a href="wherever.html">
<a href=wherever.html>
<A href="wherever.html">
<A HREF="wherever.html">
<A hReF="wherever.html">

Target is not a valid attribute in HTML 4.01 strict.

This is what I tried and it validates:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title>HTML 4.01 Test</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p><a href="wherever.html">A link</a>
<a href=wherever.html>Another link</a>
<A href="wherever.html">Another link</a>
<A HREF="wherever.html">Another link</a>
<A hReF="wherever.html">Another link</a></p>
</body>
</html>


Then I tried this and it does not validate

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title>HTML 4.01 Test</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p><a href="wherever.html" target="_top">1 link</a>
<a href="wherever.html" TARGET="_top">2 link</a>
<A href="wherever.html" target="_top">3 link</a>
<A href="wherever.html" TARGET="_top">4 link</a>
<A HREF="wherever.html" target="_top">5 link</a>
<A HREF="wherever.html" TARGET="_top">6 link</a></p>
</body>
</html>

Unfortunately, the validator throws an error only at the first occurance of target attribute. So I tried removing the "1 link", then "2 link" and so on, one by one. None of the targets validated.

- Niket

nkaisare
04-20-2003, 10:24 PM
Oh yes, coming to the question: you need to use frameset DTD to use target attribute.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
[Note: use complete DTD for compliant mode]
OR
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
[Quirks mode]

If you insist on using HTML strict, you can use javascript to open a new window:
<a href="linkhere.html" onclick="window.open('linkhere.html'); return false;">This link opens in new window, but also works if javascript is turned off</a>

khalidali63
04-20-2003, 11:20 PM
Originally posted by AWhiteC
The TARGET attribute of the A element is not allowed in strtct HTML 4.01. What's the work-around for this if you want to nominate a frame for the document to appear in, but want to remain strict?

The simple answer to your question was...use transitional / loose dtd and it will work.
My bad....

:D

nkaisare
04-20-2003, 11:56 PM
Note that <frame> are valid 4.01 Frameset DTD. Target attribute is valid in frameset and transitional DTD. HTML 4.01 Strict pages won't validate with target, but I see nothing wrong in its use (picky browsers will just ignore it, but the link should still work).

Charles
04-21-2003, 06:09 AM
It's a far, far better thing to keep with the strict DOCTYPE and use JavaScript, id est:

<a href="http://www.w3.org/" onclick="window.open(this.href); return false">W3C</a>

And you'll find that reading the 4.01 Specification, and even the 4.01 DTD, much happier than playing games with the validator. See http://www.w3.org/TR/html4/.

Charles
04-21-2003, 07:18 AM
Forty days if you don't count the Sundays. I took a little spiritual retreat from the board. Perhaps I should have applied for a leave of absence first.

pyro
04-21-2003, 07:28 AM
lol... :D It's nice to have you back, Charles.

AWhiteC
04-21-2003, 11:20 AM
I think I'll stay with doctype=strict and keep the target=_top, even though that will produce a validation error. That won't cause a problem, will it?

Charles
04-21-2003, 12:22 PM
It's just that you would be then a liar and that would be bad. If you say that you are using HTML 4.01 Strict then use 4.01 Strict. If you are using HTML 4.01 Transitional, and you are, then say that you are using 4.01 Transitional.

nkaisare
04-21-2003, 01:40 PM
Originally posted by Charles
It's just that you would be then a liar and that would be bad.
C'mon, its not that hes claiming his website to be valid HTML. I don't see any harm in it. Probably he may need the strict DTD so that browser(s) don't go into quirks mode. Worst case (in a picky browser) the file will open in the same page instead of a new page.

(BTW AWhiteC, target="_top"? you probably have frames, so you'll need frameset DTD).

Charles, does NS go in standards or quirks mode with frameset DTD?

AWhiteC
04-21-2003, 06:05 PM
In the end, I validated using doctype=strict to get rid of all the other quirks, then changed to doctype=transitional because of the Target attribute. End of story I guess!

DaveSW
04-22-2003, 04:25 AM
Originally posted by Charles
Forty days if you don't count the Sundays.

Charles: I thought Lent was after Easter not before!! :confused:

:D Lol

Dave