| 
	
 | 
 Posted by Toby Inkster on 06/25/06 09:59 
Jonathan N. Little wrote: 
 
> Bug. Not the first time. 
 
It's not a bug. For HTML the W3C validator is virtually bug-free. It has 
one or two limitations when dealing with XML, but that's about it. 
 
As David Dorwood pointed out, 
 
	<a href=http://example.org/>Example</a> 
 
is actually *invalid*, but  
 
	<a href=http://example.org/>Example 
 
is (perhaps surprisingly) *valid*! But neither means what you think it 
might mean. The reason for this is SGML's "SHORTTAG" feature which allows 
for a few odd-looking shorthands for common contructs. For example: 
 
	<b/Text/ 
 
is shorthand for: 
 
	<b>Text</b> 
 
Similarly: 
 
	<a href=http://example.org/>Example</a> 
 
is shorthand for: 
 
	<a href="http:"></a>example.org/>Example</a> 
 
And note now that you have two closing "</a>" tags, which is why it's 
invalid. 
 
The rule to take away from this is to quote attribute values. That is: 
 
	<a href="http://example.org/">Example</a> 
 
which will mean exactly what you expect it to mean. There are occasions 
when it's OK in HTML to leave out the quote marks, but it's never harmful 
to include them; so if you're unsure, always include the quote marks. 
 
--  
Toby A Inkster BSc (Hons) ARCS 
Contact Me  ~ http://tobyinkster.co.uk/contact
 
  
Navigation:
[Reply to this message] 
 |