delimiting scripts with xhtml

For technical support for all editions of CSS HTML Validator. Includes bug reports.
Post Reply
User avatar
RSteinwand
Rank VI - Professional
Rank VI - Professional
Posts: 600
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND
Contact:

delimiting scripts with xhtml

Post by RSteinwand » Thu Apr 11, 2013 10:42 am

Hi Albert,

I have both a fascination and hate relationship with xhtml.

For some reason, years ago I felt compelled to convert to xhtml strict, but wasn't ready to commit on the xml doc type, instead sticking with text/html. I thought everything was great until you and I discussed document.writes with xhtml and found out my code didn't validate via W3C, even tho CSE had no problem with it.

To make W3C happy, after reviewing this Mozilla dev page, I added comments to my scripts, but CSE doesn't like that.

Code: Select all

<script type="text/javascript">
	<!--
	function SavePrefs(){}
	function LoadPrefs(){if(emulateDesktop){InsertTopLogo();}rndtestimonial(false,true);showfeatdiv();showtradeshows();Copyright();}
	// -->
</script>
I already use external style and scripts, but this is the inline content that varies on each page.

Now I'm tempted to change to a different doc type.
Rick

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3412
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: delimiting scripts with xhtml

Post by Albert Wiersch » Thu Apr 11, 2013 10:54 am

Hi Rick,

That appears to be a 10 year old article. I think the added comments will cause more problems than they solve. I would not use them nowadays, especially in XHTML documents which can cause the script or style to be completely ignored if processed (parsed) by XML rules.

I would recommend moving to HTML5, unless you have specific needs to process your documents as XML, which it doesn't sound like you do.

Because you are already using XHTML, you might also consider polyglot documents which can be served as either HTML5 text/html or XHTML5 (application/xhtml+xml).

More information is here:
http://www.htmlvalidator.com/htmlval/v1 ... l_node.htm
Image
Albert Wiersch

User avatar
RSteinwand
Rank VI - Professional
Rank VI - Professional
Posts: 600
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND
Contact:

Re: delimiting scripts with xhtml

Post by RSteinwand » Thu Apr 11, 2013 12:40 pm

I didn't notice the page was that old.

I started converting to html5. Thanks. :D
Rick

User avatar
RSteinwand
Rank VI - Professional
Rank VI - Professional
Posts: 600
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND
Contact:

Re: delimiting scripts with xhtml

Post by RSteinwand » Mon Apr 15, 2013 8:15 pm

I'm done converting the public side and most of the secure side of our website. It was a little too easy (and disappointing)... I guess I prefer more structured rather than less, but it went well. :mrgreen:

Thanks for the suggestion.
Rick

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3412
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: delimiting scripts with xhtml

Post by Albert Wiersch » Mon Apr 15, 2013 8:28 pm

RSteinwand wrote:I'm done converting the public side and most of the secure side of our website. It was a little too easy (and disappointing)... I guess I prefer more structured rather than less, but it went well. :mrgreen:

Thanks for the suggestion.
Hi Rick,

You can make CSE HTML Validator more strict, like turning on the option to require optional end tags in the Validator Engine Options. It's in the Validator Engine->Tag Options page. There may be other options you might want to turn on as well, like requiring all attribute values to be quoted (in the Validator Engine->Attribute Options page).
Image
Albert Wiersch

User avatar
RSteinwand
Rank VI - Professional
Rank VI - Professional
Posts: 600
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND
Contact:

Re: delimiting scripts with xhtml

Post by RSteinwand » Mon Apr 15, 2013 8:41 pm

Hi Albert, my CSE is still strict, but I was disappointed that html5 is so lax. It's easier for me to learn something where there are definite rules.
Rick

Post Reply