Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Johan Hernández
Johan Hernández
4,141 Points

Conditional comments as fallback for svg

Hi, I'm trying to use this code:

<object data="img/logo.svg" type="image/svg+xml" class="chart">
<a href="img/logo.svg">
<!--[if lte IE 8]-->
<img src="img/logo.png" alt="">
<!--[endif]-->
</a>
</objetct>

(Taken from Flexible Images Part One: Vector Graphics | Team Tree House)

In order to fall back the svg logo we use the conditional comment for less or equal to IE 8, but when I test it in IE 8 or lower it shows the conditional comments (also the png) but I don't want the comments to display... Is there a way to avoid the conditional comments to display?

Thank you!

4 Answers

You have a small typo. The conditional comment should read:

<!--[if lt IE 8]-->
Johan Hernández
Johan Hernández
4,141 Points

Hi Ian, thank you for your answer, yes I see it, however I made the mistake in the question but not in the actual conditional comment in my page... is not a copy paste in other words. The one in my page is <!--[if lte IE 8 ]-->

I'll correct the mistake in the question. Thanks again!

You threw me off too ;) It should be this:

<!--[if lte IE 8]>
    Do Something
<![endif]-->
Johan Hernández
Johan Hernández
4,141 Points

Ok, I'll do it... I'm not a native english speaker, could you tell me what 'You threw me off too' means?

Thanks Ian

Done, it works just great! I wonder why in the video They use it the way I posted...