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 959965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:06:26+00:00 2026-05-16T01:06:26+00:00

What is the best way to hide inline Javascript and CSS from downlevel browsers?

  • 0

What is the best way to hide inline Javascript and CSS from downlevel browsers? … I see a few variations on a common theme. Are they all correct, or is one approach better than the other?

<script language="javascript" type="text/javascript">
<!--
    // Forces the treeview to adjust to the new size of its container
    function resizeTree(DomElementId, NewPaneHeight, NewPaneWidth) {
        //do stuff
    }

  //-->
</script>

vs

<script type="text/javascript">
//<![CDATA[
    /* Javascript code here */
//]]>
</script>

vs

  <style type="text/css">
/*<![CDATA[*/     CSS stuff here       /*]]>*/    </style>
  • 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-16T01:06:26+00:00Added an answer on May 16, 2026 at 1:06 am

    Your first example is the ancient pre-HTML 3.2 method to hide contents of the script element to browsers that didn’t recognize them. You don’t have to use it anymore. Every current browser (of which IE 6 is the oldest) recognizes these elements and knows that it shouldn’t bluntly show their contents. By the way, the language attribute of the script element has been deprecated long ago, too.

    Your second and third examples contain CDATA markers, embedded within comments appropriate for the script or style language used. Use those when you embed inline scripts or stylesheets in XHTML documents (and only then). Without those markers a parser would think that ampersands and less-than signs represent special entities or the beginning of tags, respectively. To quote Wikipedia:

    Since it is useful to be able to use
    less-than signs (<) and ampersands (&)
    in web page scripts, and to a lesser
    extent styles, without having to
    remember to escape them, it is common
    to use CDATA markers around the text
    of inline <script> and <style>
    elements in XHTML documents. But so that
    the document can also be parsed by
    HTML parsers, which do not recognise
    the CDATA markers, the CDATA markers
    are usually commented-out

    This is done the way you show in your second and third examples. The former shows a Javascript example, the latter a CSS snippet.

    Also see Comments and CDATA: The mysterious history of script and style in HTML.

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

Sidebar

Ask A Question

Stats

  • Questions 499k
  • Answers 500k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer addSubview does retain the view, that's not the problem. Your… May 16, 2026 at 1:49 pm
  • Editorial Team
    Editorial Team added an answer From what I can tell of your question, you are… May 16, 2026 at 1:49 pm
  • Editorial Team
    Editorial Team added an answer It's specific to the method executeQuery, in which ? is… May 16, 2026 at 1:49 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Bascially I want to know the best way to hide/show an ASP.NET control from
What would be the best way to hide sensitive data from being exposed when
What is the best way to hide Tab headers when there is only a
I'm trying to figure out the best way to hide certain fields in user
To make lists horizontal and hide default bullets, is it necessary to give {display:inline}
What would be the best way to position divs in any browser, so I
What is the best way of connecting some installed software with a certain computer
What's the best way to get a notification (say an event) when a keyword
What is the best way to implement action bar like twitter sample UI Pattern.
What would be the best way of designing a database to store blog posts

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.