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 trialStephen O'Connor
22,291 PointsWhy does external css override inline svg styling?
I'm just working through the SVG course and Nick uses external css to override the inline styles of an SVG when the SVG code is in the HTML.
Why do the external css styles override the inline SVG styles? This usually wouldn't happen with normal inline css.
Thanks.
2 Answers
Codin - Codesmite
8,600 PointsBecause it is not an inline style it is an attribute and external styles will override inline attributes.
For example:
This is an attribute and not an inline style:
fill="red"
This is an inline style:
style="fill:red"
example:
<svg width="500" height="500">
<text x="100" y="100" fill="red" style="fill:green">This will be green</text>
</svg>
The SVG text will be filled green because the inline style will override the fill="red" attribute. http://codepen.io/anon/pen/Ggwxmb
Laurie Williams
10,174 PointsI think it's because SVG is an attribute and CSS styles override attributes.
Stephen O'Connor
22,291 PointsStephen O'Connor
22,291 PointsMerci Buckets :)