Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1080437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:01:48+00:00 2026-05-16T22:01:48+00:00

I’m a webdeveloper with an emphasis on server-side programming. What little I’ve tinkered with

  • 0

I’m a webdeveloper with an emphasis on server-side programming. What little I’ve tinkered with JavaScript, I’ve done with externally referenced files or event handlers, and the barest minimum of an initialising function call between <script> tags.

As such it came as a surprise to me about a week ago that the data between <script> tags is not commonly escaped. In fact… it can’t be. Escaping it will throw a massive lolwut-ohnoez-wrench into the works of the JavaScript parser in, as far as I know, every browser on the face of the earth.

This leads us to the (IMO) clusterfuck that is having to use CDATA for documents with in-HTML JavaScript blocks to pass validation (in XHTML), which still breaks hilariously the moment you have ]]> in your code for any arbitrary reason.

As something of an encoding/escaping purist, I get the twitches looking at this. And for several days I’ve now asked myself:

Why?

Who’s idea was it to excempt <script> (and, for example, quite distinctly not the JS-event handlers like onclick) from the otherwise holy rule of ‘non-HTML stuff between HTML tags should be HTML escaped‘, and why? Is it a case of ‘this just grew that way historically, it’s botched now, deal with it’, or did someone sit down and think up something I’m not seeing?

The same is true (though less obviously so) for CSS and the <style> tag.

Do we even know what prompted this – or is it a case of lost knowledge? My google-fu on this topic has been incredibly weak, and I’ve not found anything, but since this is actually bugging me in pathetically OCD ways, I’d love to hear explanations if anyone has any.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:01:48+00:00Added an answer on May 16, 2026 at 10:01 pm

    Because it is very common to want to use characters such as & and < in scripts, and escaping them is a pain.

    On the flip side, <script> and <style> can’t have child elements, so there is no need to make it easy to include a tag.

    The result – HTML defines <script> and <style> as containing CDATA in the DTD, so you don’t need to do it manually in the document, thus making life easier.

    XHTML is different. In many ways XML is simpler then SGML, and its DTDs don’t (as far as I know) have that facility. Hence, you need to be explicit about CDATA markers (or use entities) in XHTML. The only reason it is a “clusterfuck” is because people claim their XHTML is HTML by serving it with a text/html content-type (instead of the correct application/xhtml+xml).

    As for intrinsic event attributes, SGML doesn’t make it possible to say that special characters should not be treated as such, but when they are used they shouldn’t contain much more than a function call … and are better avoided in favour of unobtrusive JS anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have thousands of HTML files to process using Groovy/Java and I need to
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a bunch of posts stored in text files formatted in yaml/textile (from
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.