Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"&" used in text returns Error on code validation ? 1

Status
Not open for further replies.

ramani

Programmer
Mar 15, 2001
4,336
0
0
AE
Hi

I am using
<PRE>
..... some text which contains..
.. cText&cText
</PRE>

These texts are code samples under VFP language and stands for macro substitutions. The intention is to allow users to copy the proprame code as it is and paste in their codes. However, it appears it is clashing with HTML standards.

While I do not see any errors in my browser and all appears OK, the code validation as per HTML 4 standards returns errors. (code validation done in site.. (W3C markup validation) )

SO how can I show, for example &quot;cText&cText&quot; as cText&cText without being caught as error.

Thanks :)

ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Oops, the forum &quot;swallowed&quot; my formatting. The first ampersand that you see is actually constructed like that:

& + amp + ;

(But without the pluses and spaces). You see, you have to replace certain special characters with special &quot;character entities&quot; to have a valid HTML.



regards,
rydel n23
 
Thanks Rydel. That worked. :)

ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
Oh no :-(

It worked in the HTML doc and when I see in the browser, it is fine. But the validation failed again.
What I used is &quot;cText&ampcMyText&quot; without the quotes.
It is not acceptable valid code.

Any other suggestion I could try ?
:)



ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
HI

I solved the issue. I have to use in the place
& ... &#38
This fixed the issue.

:)

ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
Just a general note, typing the amp; part twice might help dlear up the confusion when your typing &amp;amp; :)

This: &amp;amp;amp; resolves to this: &amp;amp; when your post is posted.

-Tarwn

[sub]01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101 [/sub]
[sup]29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19[/sup]
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
When showing code samples on Web pages I like the idea of replacing each < with &lt; instead.

Best regards,
J. Paul Schmidt - Freelance ASP Web Developer
- Creating &quot;dynamic&quot; Web pages that read and write from databases...
 
Oops this board apparently didn't show my code right.

Should be replace < with & l t ; but of course don't include spaces in it.

Best regards,
J. Paul Schmidt - Freelance ASP Web Developer
- Creating &quot;dynamic&quot; Web pages that read and write from databases...
 
Be warned that if you use Tarwn's double-ampersand trick to show character entities (&amp;amp; etc.) on this forum, and use the [Preview Post] button to check that you've got it right, the forum swallows the extra ampersand too! I suppose you could always use three...

-- Chris Hunt
Extra Connections Ltd
 
you could just comment it
<!-- & -->
the validator won't mind
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top