Why is here no wc3 validation error?

K

Knut Krueger

Hi all,
why is the code reported as valid?
IE and Opera will display nothing without the > after the link

Regards Knut

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=windows-1252" http-equiv="content-type" >

<title>image problem</title>
</head>
<body>
<div>
<A HREF="http://www.w3.org" <img
src="http://www.w3.org/Icons/WWW/w3c_home_nb" alt="wc3"/> </A>
</div>

</body>
</html>
 
J

John

Knut Krueger said:
Hi all,
why is the code reported as valid?
IE and Opera will display nothing without the > after the link

Regards Knut

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


<title>image problem</title>
</head>
<body>
<div>
<A HREF="http://www.w3.org" <img
src="http://www.w3.org/Icons/WWW/w3c_home_nb" alt="wc3"/> </A>
</div>

</body>
</html>

Why the forward slash after ("wc3") I'm no expert but that just doesn't look
right to me. I'm only guessing here until someone comes along that may be of
more help to you.
 
J

John Hosking

Knut said:
Hi all,
why is the code reported as valid?
IE and Opera will display nothing without the > after the link

I don't know. Maybe Jukka or Ben or somebody experienced in reading DTDs
can explain why it's allowed.

I pasted your code into the "Validate by Direct Input" box at
http://validator.w3.org/ and found that the code is indeed deemed to be
valid. Also valid is this simpler variant:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>More of a Parse Question</title>
</head>
<body>
<p>
<A </A>
</p>
</body>
</html>

I can only guess that this is an instance of one of those little-known
auto-terminating tags (although it doesn't seem to be a proper "null end
tag") that seem to work because they are rooted in SGML, but which
nobody (like, say, browser developers) knows about.

Sorry I can't be of more help. I'm interested in knowing the answer, too.
 
B

Benjamin Niemann

Hello,

Knut said:
why is the code reported as valid?
IE and Opera will display nothing without the > after the link

Regards Knut

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


<title>image problem</title>
</head>
<body>
<div>
<A HREF="http://www.w3.org" <img
src="http://www.w3.org/Icons/WWW/w3c_home_nb" alt="wc3"/> </A>
</div>

</body>
</html>

The '<A ... ' followed by '<img ...' is a so-called 'unclosed start-tag'
[1], which is valid SGML syntax, but not supported by 'tag-soup' parsers
found in browsers.
There's also a XMLish '<img .. />' tag in there, which is valid in this
context, but - when parser by the SGML rules - not what you want, though
probably treat the '/' as a syntax error which is silently ignored.

Reporting such things is beyond the scope of a markup validator, though it
may be of great help for web authors.

HTH

[1]: If the start-tag is immediately followed by a TAGO '<' or STAGO '</',
you may omit the TAGC '>'.
 
H

Harlan Messinger

Knut said:
Hi all,
why is the code reported as valid?
IE and Opera will display nothing without the > after the link

Regards Knut

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=windows-1252" http-equiv="content-type" >

<title>image problem</title>
</head>
<body>
<div>
<A HREF="http://www.w3.org" <img
src="http://www.w3.org/Icons/WWW/w3c_home_nb" alt="wc3"/> </A>
</div>

</body>
</html>

http://www.is-thought.co.uk/book/sgml-9.htm#Unclosed
 
D

dorayme

Benjamin Niemann said:
Hello,

Knut said:
why is the code reported as valid?
IE and Opera will display nothing without the > after the link

Regards Knut

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


<title>image problem</title>
</head>
<body>
<div>
<A HREF="http://www.w3.org" <img
src="http://www.w3.org/Icons/WWW/w3c_home_nb" alt="wc3"/> </A>
</div>

</body>
</html>

The '<A ... ' followed by '<img ...' is a so-called 'unclosed start-tag'
[1], which is valid SGML syntax, but not supported by 'tag-soup' parsers
found in browsers.
There's also a XMLish '<img .. />' tag in there, which is valid in this
context, but - when parser by the SGML rules - not what you want, though
probably treat the '/' as a syntax error which is silently ignored.

Reporting such things is beyond the scope of a markup validator, though it
may be of great help for web authors.

BBedit text editor reports

Unencoded entity found; "<" needs to be encoded as "&lt;".

Document type doesn't permit empty XML element; "<img/>".

Close element "</a>" found but element wasn't open.

The iCab browser, which refuses to show anything on the page at
all, reports:

HTML error (12/57): The attribute "<IMG" in tag <A> is not
allowed.
HTML error (12/57): The attribute "SRC" in tag <A> is not allowed.
HTML error (12/57): The attribute "ALT" in tag <A> is not allowed.
HTML error (12/57): Illegal character "/" in tag.

Opera refuses too.

Safari happily displays the logo, so too does the innocent and
good old Mac IE 5
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top