homepage Welcome to WebmasterWorld Guest from 50.17.79.35
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
conditional comments
do not validate
nyteshade




msg:4415450
 3:07 pm on Feb 8, 2012 (gmt 0)

I recently discovered 'compatibility view' in IE8. Why and how? after 2.5 years of learning (primarily on Firefox) this HTTP stuff? By way of explanation: I sent a former employer my domain and she replied that 'it is kind of jumbled' but admitted that she was stuck with IE6 (a Fortune 500 company!). So, I've spent the past week implementing very limited use of conditional comments, absolutely NO CSS hacks, and I'm not trying to emulate current technologies to work in IE6 simply for appearance sake. I've simply taken into account: absolute positioning, min-width, max-width and setAttribute.

What I've decided is if IE6 cannot render a page as I've built it then I'm not allowing it to invoke the page. So, I started with:


<!-- [if gte IE 8]>
*** allow IE8+ and all other user-agents ***
<![endif]-->


But what I discovered was that Google Chrome, Opera, FF were also denied. After reviewing conditional comments(CCs) again at[msdn.microsoft.com ] which, to microsofts credit, does give a detailed description, I came to understand that 'down-level hidden' excludes browsers that are mute to CCs; I then tried this:


<![if gte IE 8]>
***allow IE8+ et al ***
<![endif]>


...which is 'down-level revealed'; works but will not validate because CCs revealed are not valid HTML. So, my question is, is there a way to implement CCs to do what I want them to do and validate? If not then is there a 'standard' feature detection way that folks use that I'm not aware of?

Here is the actual HTML I'm working with:

<![if gte IE 8]>
<li><a href="js_planets_gallery.shtml" class="textLink">Planets of the Solar System</a>:
<abbr title="HyperText Markup Language">HTML</abbr>,
<abbr title="Cascading Style Sheet">CSS</abbr>,
<abbr title="Document Object Model">DOM</abbr> scripting using JavaScript</li>
<![endif]>


Thanks all.

 

Fotiman




msg:4415467
 3:35 pm on Feb 8, 2012 (gmt 0)

<!--[if gte IE 8]-->
*** allow IE8+ and all other user-agents ***
<!--[endif]-->

nyteshade




msg:4415487
 4:17 pm on Feb 8, 2012 (gmt 0)

Yes Fotiman, I tried that before my original posting but thought it was not entirely legal, but even though the other browsers (GC,FF,O) handle those conditional comments as expected, IE8 in compatibility view and not, actually displays the conditional comments and their contents on screen?!? BTW: I'm using Windows XP SP3 using IE8.

Ok, just returned from the MS site again and in the Community Additions of the page a poster posted (3/11/2010) this for just the problem described above:


Fixing Validation Errors

The downlevel-revealed conditional comment syntax is flagged as invalid HTML by some validation services. Additional characters can be added to construct a valid HTML Comment before and after the HTML content to be revealed.

<!--[if !IE]>--> HTML <!--<![endif]-->

In the example above, the negative conditional expression prevents Internet Explorer from displaying the HTML content within the downlevel-revealed conditional comment block. However, if the conditional expression evaluates to true, the closing "-->" of the first comment appears along with the HTML content in Internet Explorer. To hide these characters from Internet Explorer users, add "<!" as follows:

<!--[if !IE]><!--> HTML <!--<![endif]-->


And it works and validates, am happy now. I should have read the Community Additions to the MS page initially.

Fotiman




msg:4415502
 4:45 pm on Feb 8, 2012 (gmt 0)

Huh. That's weird.

lucy24




msg:4415644
 11:28 pm on Feb 8, 2012 (gmt 0)

You don't need the all-encompassing "if IE" do you? MS claims that MSIE 10 will no longer recognize CCs (thread somewhere in these Forums). Conversely, they only came into use with MSIE 5.* So the only thing you need to code for is MSIE in the 5-7 range. Forward compatibility isn't an issue.


* There exist humans who still use MSIE 5, but I have never met a non-robot using anything older. And those MSIE 5 users are on Macs, which apparently never recognized the CC.

nyteshade




msg:4416099
 11:38 pm on Feb 9, 2012 (gmt 0)

lucy24 - thanks for the headsup re ie10. I'm actually planning on removing CCs completely as soon as I replace setAttribute in my DOM examples with the respective HTML-DOM properties.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved