View Full Version : Impossible to validate a document that uses html in arrays?
12-19-2003, 09:47 AM
I have a page I'm trying to validate with the http://validator.w3.org and it's claiming that my arrays containing html are in the wrong spot. They're not in a paragraph tag so it complains. But those arrays are written into table cells when used which is perfectly valid. Is this one of those limitations of the validator? I guess not all pages can be validated. The url to the page I'm refering to is http://www.techsonic.net/xfox/goods.
wouldn't be the full syntax of a new class of objects a better way?:
var C = new Array(44)
... but I don't think this is the unvalidate reason....
12-19-2003, 11:40 AM
It's validating the HTML as it sees it - <a> is not allowed as a direct child of <script> and so it throws an error.
Scripting in XHTML should be in a <![CDATA[ section .. but you shouldn't really put <![CDATA[ sections in HTML, so if you're not serving as XML then the thing to do is take the script out and put it in an external JS file - then the validator won't see it.
12-19-2003, 09:07 PM
I'm not sure about that. It checks for linked files. For an external css file on another page, it validated that as part of the XHTML 1.0 check. http://www.techsonic.net/xfox/old/upd02.htm is the fully redone and validated page so far.
Edit: Aha, problem solved. It requires comment tags in the script tag. Just regular old comments (I've never encountered a CDATA before).
12-19-2003, 10:54 PM
No - not comments, never put HTML comments inside <script>. A validating parser is not required to process comments - and indeed, in a page served as XML the script won't run at all.
But without comments it's visible to legacy browsers. So it's better always to put scripting in external JS files.
The validator should not be validating external files. Possibly there's an option for validating CSS at the same time, I don't know, but afaik the validator will not open and try to validate an external JS file. It's always worked for me.
12-20-2003, 09:11 PM
I've got a few pages fully validated now. But one problem comes up for links. is the & character allowed in urls? Some have them but it says it's a delimiter and shouldn't be used as data. You can't just change an url though can you?
12-20-2003, 09:16 PM
Replaces all instances of & with it's equivalent entity:
12-20-2003, 09:30 PM
Doing that would apparently make the url an invalid link.
12-20-2003, 10:02 PM
No it wouldn't.
12-20-2003, 11:42 PM
Ah, okay. It works as long as the browser converts it (I don't think all of them do however). And the address bar doesn't do the conversion if you paste the entity version.
12-21-2003, 12:58 PM
Possibly not, but if you're pasting it you won't use the entitity; and if someone copies-and-pastes it from your page, they'll get a raw ampersand as well, because that's what's displayed. It's when you insert that character in your source code that it needs to be an entity.
When you say you don't think all browsers will work with that - on what basis are you saying that? Superstition, or you have a practical example of it not working?
Built a test page, works in IE4-6, Moz. Didn't test it in any others. Anyway, the page:
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.