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

HTML

Add SVG to a page

How do you put an svg into a ul li? Can anyone kindly help?

<nav>
    <ul>
        <li><a href="#" title="Home">Home</a></li>
        <li><a href="#" title="About">About</a></li>
        <li>
            <object class="logo" data="img/logo.svg" type="image/svg+xml"></object>
        </li> 
        <li><a href="#" title="Work">Work</a></li>
        <li><a href="#" title="Contact">Contact</a></li>
    </ul>
</nav>

Moved this thread to the HTML topic. Just a reminder that questions posed in General Discussion can not be marked with a best answer.

7 Answers

Heres how some code for an SVG look from the header of the site I'm currently working on.

<object data="media/Logo70.svg" type="image/svg+xml" class="headerlogo"></object>

This wrapped in a <li> tag should work, just swap out the "data" and get rid of/ change the "class".

<nav> <ul> <li><a href="#" title="Home">Home</a></li> <li><a href="#" title="About">About</a></li> <li><object class="logo" data="img/logo.svg" type="image/svg+xml"> </object> </li> <li><a href="#" title="Work">Work</a></li> <li><a href="#" title="Contact">Contact</a></li> </ul> </nav>

<nav> <ul> <li><a href="#" title="Home">Home</a></li> <li><a href="#" title="About">About</a></li> <li><object class="logo" data="img/logo.svg" type="image/svg+xml"> </object> </li> <li><a href="#" title="Work">Work</a></li> <li><a href="#" title="Contact">Contact</a></li> </ul> </nav>

You can display code by wrapping it in " `` ".

" "<nav> <ul> <li><a href="#" title="Home">Home</a></li> <li><a href="#" title="About">About</a></li> <li><object class="logo" data="img/logo.svg" type="image/svg+xml"> </object> </li> <li><a href="#" title="Work">Work</a></li> <li><a href="#" title="Contact">Contact</a></li> </ul> </nav> " "

Thanks Chase. that really helped

Excellent thanks!