Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Ian Lunn
Ian Lunn
4,558 Points

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!

Ian Lunn
Ian Lunn
4,558 Points

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...