Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Design why every template using "no-js" class?

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #249321
    Pranab
    Participant

    Here is an example from the HTML5 Boilerplate:

    <!--[if IE 8 ]>    <html lang="en" class="no-js ie8"> <![endif]-->
    <!--[if IE 9 ]>    <html lang="en" class="no-js ie9"> <![endif]-->
    <!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
    

    what is the purpose of this?

    #249323
    Beverleyh
    Participant

    The conditional comments allow different HTML elements, and therefore different browser-specific classes, to render in their respective browsers. It’s a way of identifying older versions of IE in order to apply specific styles.

    If you need to research further, just Google “conditional comments”.

    #249326
    Beverleyh
    Participant

    Sorry I misinterpreted – skim reading the post without reading the title. There is a ‘no-js’ class in the markup by default, and JavaScript removes it when JavaScript is available. When JavaScript isn’t available, for whatever reason, the class stays in the markup. It is so elements can be styled differently depending on whether JavaScript is available or not.

    #249327
    Pranab
    Participant

    so if i don’t include this in html markup, then what happen? Is this necessary to include in every html page?and why js removes it? if not remove then what happen?

    #249328
    Beverleyh
    Participant

    so if i don’t include this in html markup, then what happen?

    You won’t be able to apply styles for elements in no-js circumstances. You’d have to use some other fallback.

    Is this necessary to include in every html page?

    That depends if you’re using JavaScript to render critical elements. Again, you’d have to consider fallbacks for when JS is unavailable.

    why js removes it?

    To make its presence known and remove styles that have been applied in no-js circumstances.

    if not remove then what happen?

    The class remains in the markup and can be used to style elements differently when JS is unavailable.

    This is all getting a bit repetitive so you should do some research via Google. Here’s a place to start
    http://stackoverflow.com/questions/6724515/what-is-the-purpose-of-the-html-no-js-class

    #249329
    Pranab
    Participant

    thanks Beverleyh…

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Design’ is closed to new topics and replies.