SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Jul 2002
    Location
    space
    Posts
    845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Validating non-javascript version

    Hello,

    I'm using noscript for a non-js version. The XHTML 1.0 validator doesn't seem to like the style element within <noscript>

    Are there any workarounds for this?

    Code:
     <object>
            <noscript>
                <style type="text/css">
    
                styles here
    
                </style>
            </noscript>
            </object>

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,870
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    <noscript> is obsolete. Using JavaScript provides a more flexible alternative.

    1. Styles are only allowed in the <head>
    2. <noscript was only allowed in the body. HTML 5 allows it anywhere but it hasn't been necessary to use it at all since Netscape 4.

    To style differently when JavaScript is not available add class=nojs" to the <head> tag and use that class as part of all your no JavaScript styling in your regular CSS file.

    Then simply include a one line JavaScript in the head of the page that removes the nojs class from the head tag.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Guru
    Join Date
    Jul 2002
    Location
    space
    Posts
    845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the response. We are soon moving to HTML 5 where noscript will be allowed in <head>.

    I'm just wondering if there is some kind of "hack" or workaround to make it compliant with XHTML 1.0 Strict, without modifying the code very much.

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by johnny190 View Post
    Thanks for the response. We are soon moving to HTML 5 where noscript will be allowed in <head>.

    I'm just wondering if there is some kind of "hack" or workaround to make it compliant with XHTML 1.0 Strict, without modifying the code very much.
    Even though you are moving soon to HTML 5, are you going to restrict access from all browsers that don't handle HTML 5? It is normally a better practice to ensure that your techniques are widely accessible.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,870
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by johnny190 View Post
    Thanks for the response. We are soon moving to HTML 5 where noscript will be allowed in <head>.
    Just because they allow an obsolete tag to be used anywhere doesn't mean you should use it.


    See http://www.felgall.com/jstip180.htm for a one line JavaScript that allows you to style the entire page completely differently depending on whether JavaScript is enabled or not without needing the obsolete noscript tag.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •