Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > validating quoted ampersands

Reply
Thread Tools

validating quoted ampersands

 
 
mouse@house.spam
Guest
Posts: n/a
 
      09-23-2006
I have a reference to a web counter in my page, which according to my
ISP should look like;

<IMG SRC="/cgi-sys/Count.cgi?df=sigma-index.html&st=1000">

However the W3 validator wails about the ampersand '&' before the st.
It insists the line must look like;

<img src="/cgi-sys/Count.cgi?df=c-compiler-com-root&amp;ft=0&amp;dd=D"
title="Counter" alt="Counter">

in other words we must use &amp; instead of just &

Is this how valid HTML must specify an ampersand? Both versions seem
valid in my web browser. The &amp; version looks a bit strange and I
am surprised that W3 validator regards it as necessary.
 
Reply With Quote
 
 
 
 
dfloss
Guest
Posts: n/a
 
      09-23-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I have a reference to a web counter in my page, which according to my
> ISP should look like;
>
> <IMG SRC="/cgi-sys/Count.cgi?df=sigma-index.html&st=1000">
>
> However the W3 validator wails about the ampersand '&' before the st.
> It insists the line must look like;
>
> <img src="/cgi-sys/Count.cgi?df=c-compiler-com-root&amp;ft=0&amp;dd=D"
> title="Counter" alt="Counter">
>
> in other words we must use &amp; instead of just &
>
> Is this how valid HTML must specify an ampersand? Both versions seem
> valid in my web browser. The &amp; version looks a bit strange and I
> am surprised that W3 validator regards it as necessary.


& is a very dubious html delimiter. &amp; is how it should be done
 
Reply With Quote
 
 
 
 
David Dorward
Guest
Posts: n/a
 
      09-23-2006
(E-Mail Removed) wrote:

> I have a reference to a web counter in my page, which according to my
> ISP should look like;
>
> <IMG SRC="/cgi-sys/Count.cgi?df=sigma-index.html&st=1000">


Your ISP is wrong.

> However the W3 validator wails about the ampersand '&' before the st.
> It insists the line must look like;
>
> <img src="/cgi-sys/Count.cgi?df=c-compiler-com-root&amp;ft=0&amp;dd=D"
> title="Counter" alt="Counter">


Only if you are changing the data you want to pass to Count.cgi.

> in other words we must use &amp; instead of just &


Yes

> Is this how valid HTML must specify an ampersand?


Yes

> Both versions seem valid in my web browser.


No, your browser is capable of some degree of error correction.

> The &amp; version looks a bit strange and I am surprised that W3 validator
> regards it as necessary.


What if, for example, the piece of data was called "copy" instead of "st"?
The spec has to have come way of distingushing between an ampersand
followed by the word "copy" and the entity meaning "The copyright symbol".

(Follow-ups set)

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
 
Reply With Quote
 
richard
Guest
Posts: n/a
 
      09-24-2006

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a reference to a web counter in my page, which according to my
> ISP should look like;
>
> <IMG SRC="/cgi-sys/Count.cgi?df=sigma-index.html&st=1000">
>
> However the W3 validator wails about the ampersand '&' before the st.
> It insists the line must look like;
>
> <img src="/cgi-sys/Count.cgi?df=c-compiler-com-root&amp;ft=0&amp;dd=D"
> title="Counter" alt="Counter">
>
> in other words we must use &amp; instead of just &
>
> Is this how valid HTML must specify an ampersand? Both versions seem
> valid in my web browser. The &amp; version looks a bit strange and I
> am surprised that W3 validator regards it as necessary.


Web counter?
I had one with a free service once. Got the same results from the validator.
Included the "amp" and all was happy.
It really is much nicer to have a host that has all that stuff built in.

 
Reply With Quote
 
cwdjrxyz
Guest
Posts: n/a
 
      09-24-2006

(E-Mail Removed) wrote:
> I have a reference to a web counter in my page, which according to my
> ISP should look like;
>
> <IMG SRC="/cgi-sys/Count.cgi?df=sigma-index.html&st=1000">
>
> However the W3 validator wails about the ampersand '&' before the st.
> It insists the line must look like;
>
> <img src="/cgi-sys/Count.cgi?df=c-compiler-com-root&amp;ft=0&amp;dd=D"
> title="Counter" alt="Counter">
>
> in other words we must use &amp; instead of just &
>
> Is this how valid HTML must specify an ampersand? Both versions seem
> valid in my web browser. The &amp; version looks a bit strange and I
> am surprised that W3 validator regards it as necessary.


If you click the "Help and FAQ" tab at the W3C validator, you get a
reference to a page that states:

__________________________________________________ _____________________


Another common error occurs when including a URL which contains an
ampersand ("&"):

<!-- This is invalid! --> <a
href="foo.cgi?chapter=1&section=2&copy=3&lang=en"> ...</a>

This example generates an error for "unknown entity section" because
the "&" is assumed to begin an entity reference. Browsers often recover
safely from this kind of error, but real problems do occur in some
cases. In this example, many browsers correctly convert &copy=3 to
©=3, which may cause the link to fail. Since &lang; is the HTML entity
for the left-pointing angle bracket, some browsers also convert
&lang=en to <=en. And one old browser even finds the entity &sect;,
converting &section=2 to §ion=2.

To avoid problems with both validators and browsers, always use &amp;
in place of & when writing URLs in HTML:

<a
href="foo.cgi?chapter=1&amp;section=2&amp;copy=3&a mp;lang=en">...</a>

Note that replacing & with &amp; is only done when writing the URL in
HTML, where "&" is a special character (along with "<" and ">"). When
writing the same URL in a plain text email message or in the location
bar of your browser, you would use "&" and not "&amp;". With HTML, the
browser translates "&amp;" to "&" so the Web server would only see "&"
and not "&amp;" in the query string of the request.

__________________________________________________ ______________________

The url of the above is:
http://www.htmlhelp.com/tools/valida...blems.html#amp .

If you do not agree with the above, go to the W3C validator and click
the "feedback" tab. I am only the messenger . There likely is
discussion of this in the official W3C specifications for html, but I
do not have time to check this tome at the moment.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
c:url encoding issue with ampersands johkar Java 0 02-25-2006 05:00 PM
how to properly encode ampersands in querystring darrel ASP .Net 14 06-14-2005 07:12 PM
Naming of ampersands and other tricky characters Andy Dingley XML 1 06-10-2004 03:34 PM
Links/ampersands in HTML tags using XML/XSLT SDM XML 2 09-22-2003 02:01 PM
Ampersands being converted when in data that is bound to my ASP:Dropdown Howard, Brett ASP .Net 1 07-12-2003 06:39 AM



Advertisments