</A> not needed?

S

Samuël van Laere

I've allway's thought this was correct:
<ul>
<li><a href=http://www.someurltoadd.com>Click Me</a></li>
</ul>

But it isn't.

The W3C HTML Validator doesn't want the ending </a> tag there.
Why is that?
I mean, it looks better with right?

Cheers,
Sam
 
M

mbstevens

I've allway's thought this was correct:
<ul>
<li><a href=http://www.someurltoadd.com>Click Me</a></li>
</ul>

But it isn't.

The W3C HTML Validator doesn't want the ending </a> tag there.
Why is that?
I mean, it looks better with right?

There is a server error on that address,
so I can't look at the source. But you are
probably not using a doc type that uses a closing tag.
Go to w3c org and read about doc types.
 
S

Samuël van Laere

There is a server error on that address,
so I can't look at the source. But you are
probably not using a doc type that uses a closing tag.
Go to w3c org and read about doc types.

The address is:
http://www.oukje.nl/
Everything validates, includes a doctype and everything.

Any thoughts?

Cheers,
Sam
 
S

Samuël van Laere

mbstevens said:
There is a server error on that address,
so I can't look at the source. But you are
probably not using a doc type that uses a closing tag.
Go to w3c org and read about doc types.


Its wierd.
When I add the closing href tag </a> the validator
won't validate the website succesfull.
And without it, it will.
Could it be because of UTF8?

Cheers,
Sam
 
D

dorayme

Samuël van Laere said:
I've allway's thought this was correct:
<ul>
<li><a href=http://www.someurltoadd.com>Click Me</a></li>
</ul>

But it isn't.

The W3C HTML Validator doesn't want the ending </a> tag there.
Why is that?
I mean, it looks better with right?

Cheers,
Sam

You need the closing, also, put " " around the url...
 
M

mbstevens

Bug. Not the first time. The closing tag is not optional see:

http://www.w3.org/TR/html4/struct/links.html#edef-A

"Start tag: required, End tag: required"

Yes, I think you're right. The validator is claiming there was no <a...>
tag. There is an empty <a></a> pair above the first error link that may
have caused the validator to make a mistake, I don't know.

I would advise the op to
indent the markup in a readable way (no 500+ character lines!). This seems
to be my pet peeve today, but why would one post markup to a group that
places entire <ul>....</ul> blocks on a single line? Are we expected to
read this stuff? The rest of the page is formatted for human readers. Why
not at least get the line with the error on it humanly readable before
posting? It might just clear up the problem.
 
D

David Dorward

Samuël van Laere said:
<li><a href=http://www.someurltoadd.com>Click Me</a></li>
The W3C HTML Validator doesn't want the ending </a> tag there.
Why is that?

It is an oddity of SGML. Even though browsers don't generally support it,
the first slash character in the URL ends the tag, and the second ends the
element.

What you have there is, IIRC, the same as:

<li><a href="http:"></a>www.someurltoadd.com&gt;Click Me</a></li>

If an attribute consists only of certain characters, then quotes are
optional, but its easier not to try to remember those excepts and simply
work to the rule "Always quote attribute values".

http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2
 
T

Toby Inkster

Jonathan said:
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/&gt;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.
 
L

Leonard Blaisdell

Toby Inkster said:
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.

How about making it a personal rule to always quote attribute values
instead of guessing what one could get away with. I'm pretty sure I know
what I can get away with, but I always quote attributes values.
I think that's a logical two cents or two pence

leo
 

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

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top